From deb99942d3b75d638935e31d2736ba076396e696 Mon Sep 17 00:00:00 2001 From: neri Date: Sun, 12 Jul 2020 00:16:36 +0200 Subject: [PATCH] add not yet working multi stage docker build --- Dockerfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..39f4a48 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM postgres as builder + +ENV POSTGRES_USER "datatrash" +ENV POSTGRES_PASSWORD "secure" + +RUN apt-get update +RUN apt-get install --yes curl build-essential +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-install.sh +RUN sh rustup-install.sh -y +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup target add x86_64-unknown-linux-musl + +ENV USER rust +WORKDIR / +RUN cargo new --bin datatrash +WORKDIR /datatrash +COPY Cargo.lock Cargo.lock +COPY Cargo.toml Cargo.toml +RUN cargo build --release --target=x86_64-unknown-linux-musl --features vendored +RUN rm src/*.rs + +COPY src src +ENV DATABASE_URL "postgresql://datatrash:secure@localhost" +RUN rm target/release/deps/datatrash* +RUN cargo build --release --target=x86_64-unknown-linux-musl --features vendored +RUN strip target/release/horrible + +FROM SCRATCH +COPY --from=builder /datatrash/target/release/datatrash /datatrash +ENTRYPOINT ["/datatrash"]