From 76fd093756ab387b51518c0792dc342060c58ade Mon Sep 17 00:00:00 2001 From: neri Date: Tue, 4 Aug 2020 23:43:50 +0200 Subject: [PATCH] improve dockerfile dependency caching and file system structure --- Dockerfile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 003bff3..2f248c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ekidd/rust-musl-builder as build +FROM ekidd/rust-musl-builder:latest as build USER rust WORKDIR /home/rust/src/ @@ -13,14 +13,20 @@ COPY --chown=rust static ./static COPY --chown=rust template ./template COPY --chown=rust init-db.sql ./init-db.sql RUN touch src/main.rs -RUN cargo install --path . --features vendored +RUN cargo build --release --features vendored -FROM alpine +FROM alpine:latest ENV RUST_BACKTRACE "1" -COPY --from=build /home/rust/.cargo/bin/datatrash . -COPY static ./static -RUN mkdir ./files +RUN mkdir /opt/datatrash +WORKDIR /opt/datatrash + +COPY --from=build \ + /home/rust/src/datatrash/target/x86_64-unknown-linux-musl/release/datatrash \ + /opt/datatrash/ +COPY static /opt/datatrash/static +RUN mkdir /opt/datatrash/files + EXPOSE 8000 -ENTRYPOINT ["./datatrash"] +ENTRYPOINT ["/opt/datatrash/datatrash"]