From 84d96564186a766ed5fd378255508226e18d67ca Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Sun, 24 Mar 2024 21:01:34 +0200 Subject: [PATCH] chore(docker): optimize dockerfile --- .dockerfile | 8 ++++++++ Dockerfile | 20 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 .dockerfile diff --git a/.dockerfile b/.dockerfile new file mode 100644 index 0000000..838ea02 --- /dev/null +++ b/.dockerfile @@ -0,0 +1,8 @@ +.env +target/ +tests/ +Dockerfile +README.md +LICENSE +scripts/ +migrations/ diff --git a/Dockerfile b/Dockerfile index 2d25727..bd556cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,24 @@ -FROM rust:1.77.0 +FROM rust:1.77.0 AS builder + WORKDIR /app RUN apt-get update && apt-get install lld clang -y COPY . . ENV SQLX_OFFLINE true RUN cargo build --release + + +FROM debian:bookworm-slim AS runtime +WORKDIR /app +# Install OpenSSL - it is dynamically linked by some of our dependencies +# Install ca-certificates - it is needed to verify TLS certificates when establishing HTTPS connections +RUN apt-get update -y \ + && apt-get install -y --no-install-recommends openssl ca-certificates \ + # Clean up + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /app/target/release/zero2prod zero2prod +COPY config config ENV APP_ENVIRONMENT production -ENTRYPOINT ["./target/release/zero2prod"] +ENTRYPOINT ["./zero2prod"]