From 2b13f0f58679d6c3958da0c05d42e2c71172f16d Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Wed, 24 Jul 2019 17:54:54 +0200 Subject: [PATCH] Implement docker build --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f178fb2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM ekidd/rust-musl-builder:stable as builder + +# RUN adduser -D hoc +RUN useradd -U 10001 dummy + +# create new cargo project +RUN USER=rust cargo init --bin +# copy build config +COPY --chown=rust ./Cargo.lock ./Cargo.lock +COPY --chown=rust ./Cargo.toml ./Cargo.toml +# build to cache dependencies +RUN cargo build --release +# delete build cache to prevent caching issues later on +RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/gitache-* + +COPY ./src ./src +# build source code +RUN cargo build --release + +FROM scratch + +COPY --from=builder /etc/passwd /etc/passwd +USER dummy + +COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/gitache / + +ENTRYPOINT ["/gitache"]