build: reduce podman/docker image size
This commit is contained in:
parent
9dde52c1cd
commit
a25cb5a7ef
2 changed files with 20 additions and 2 deletions
6
.dockerignore
Normal file
6
.dockerignore
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
.env
|
||||||
|
target/
|
||||||
|
tests/
|
||||||
|
Dockerfile
|
||||||
|
scripts/
|
||||||
|
migrations/
|
||||||
16
Dockerfile
16
Dockerfile
|
|
@ -1,8 +1,20 @@
|
||||||
FROM docker.io/rust:1.75.0
|
# Builder stage
|
||||||
|
FROM rust:1.75.0 AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apt update && apt install lld clang -y
|
RUN apt update && apt install lld clang -y
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV SQLX_OFFLINE true
|
ENV SQLX_OFFLINE true
|
||||||
RUN cargo build --release
|
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
|
ENV APP_ENVIRONMENT production
|
||||||
ENTRYPOINT ["./target/release/learn_axum"]
|
ENTRYPOINT ["./zero2prod"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue