From 64ac7de8317d7a561bb91d72684d20bdda5bdc19 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 16 Apr 2019 16:57:24 +0200 Subject: [PATCH] Implement docker build --- .dockerignore | 1 + Dockerfile | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +/target diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b36c8c3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM ekidd/rust-musl-builder:stable as builder + +# create new cargo project +RUN USER=rust cargo init --bin +# set last modified date to 1970-01-01 to prevent caching issues later on +# RUN touch -t 197001010000.00 src/main.rs +# copy build config +COPY ./Cargo.lock ./Cargo.lock +COPY ./Cargo.toml ./Cargo.toml +# build to cache dependencies +RUN cargo build --release +# RUN ls target/x*/release +# RUN touch -t 197001010000.00 ./target/x86_64-unknown-linux-musl/release/hoc.d +RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/hoc-* + +# copy source code +COPY ./src ./src +# build source code +RUN cargo build --release + +FROM alpine:latest + +COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/hoc /hoc