improve dockerfile dependency caching and file system structure

This commit is contained in:
neri 2020-08-04 23:43:50 +02:00
parent 2eb816134d
commit 76fd093756
1 changed files with 13 additions and 7 deletions

View File

@ -1,4 +1,4 @@
FROM ekidd/rust-musl-builder as build FROM ekidd/rust-musl-builder:latest as build
USER rust USER rust
WORKDIR /home/rust/src/ WORKDIR /home/rust/src/
@ -13,14 +13,20 @@ COPY --chown=rust static ./static
COPY --chown=rust template ./template COPY --chown=rust template ./template
COPY --chown=rust init-db.sql ./init-db.sql COPY --chown=rust init-db.sql ./init-db.sql
RUN touch src/main.rs 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" ENV RUST_BACKTRACE "1"
COPY --from=build /home/rust/.cargo/bin/datatrash . RUN mkdir /opt/datatrash
COPY static ./static WORKDIR /opt/datatrash
RUN mkdir ./files
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 EXPOSE 8000
ENTRYPOINT ["./datatrash"] ENTRYPOINT ["/opt/datatrash/datatrash"]