From 6b60399c5fb07ac883a615635ee4188390190429 Mon Sep 17 00:00:00 2001 From: neri Date: Tue, 26 Oct 2021 23:31:21 +0200 Subject: [PATCH] migrate Dockerfile away from rust-musl-builder --- Dockerfile | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index a9d109c..03d0994 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,29 @@ -FROM ekidd/rust-musl-builder:beta as build +FROM rust:alpine3.14 as builder -USER rust -WORKDIR /home/rust/src/ -RUN USER=rust cargo new datatrash +WORKDIR /app +RUN apk add musl-dev -WORKDIR /home/rust/src/datatrash -COPY --chown=rust Cargo.toml Cargo.lock ./ -RUN cargo build --release +RUN cargo init +COPY Cargo.toml Cargo.lock ./ +RUN cargo build --release --target=x86_64-unknown-linux-musl -COPY --chown=rust src ./src -COPY --chown=rust static ./static -COPY --chown=rust template ./template -COPY --chown=rust snippet ./snippet -COPY --chown=rust init-db.sql ./init-db.sql +COPY src ./src +COPY static ./static +COPY template ./template +COPY snippet ./snippet +COPY init-db.sql ./init-db.sql RUN touch src/main.rs -RUN cargo build --release -RUN strip target/x86_64-unknown-linux-musl/release/datatrash +RUN cargo build --release --target=x86_64-unknown-linux-musl +RUN strip /app/target/x86_64-unknown-linux-musl/release/datatrash -FROM alpine:latest -ENV RUST_BACKTRACE "1" -RUN mkdir /opt/datatrash +FROM alpine:3.14 + 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 +COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/datatrash ./ +COPY static ./static +RUN mkdir ./files EXPOSE 8000 ENTRYPOINT ["/opt/datatrash/datatrash"]