diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5d2a7ec --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.env +target/ +tests/ +Dockerfile +scripts/ +migrations/ diff --git a/Dockerfile b/Dockerfile index 31f71e2..c72c594 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,20 @@ -FROM docker.io/rust:1.75.0 +# Builder stage +FROM rust:1.75.0 AS builder + WORKDIR /app RUN apt update && apt install lld clang -y COPY . . ENV SQLX_OFFLINE true RUN cargo build --release + +# Runtime stage +FROM rust:1.75.0-slim AS runtime + +WORKDIR /app +# Copy the compiled binary from the builder environment +# to our runtime environment +COPY --from=builder /app/target/release/learn_axum zero2prod +# We need the configuration file at runtime! +COPY configuration configuration ENV APP_ENVIRONMENT production -ENTRYPOINT ["./target/release/learn_axum"] +ENTRYPOINT ["./zero2prod"]