Skip to content

Commit

Permalink
feat(dockerfile): Improve size and layering
Browse files Browse the repository at this point in the history
  • Loading branch information
Yag000 committed Sep 1, 2023
1 parent 8200d19 commit 1999f96
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.env
.dockerignore
spec.yaml
target/
deploy/
tests/
Dockerfile
scripts/
Expand Down
27 changes: 24 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
FROM rust:1.71.0
FROM lukemathwalker/cargo-chef:latest-rust-1.71 as chef

WORKDIR /app
RUN apt update && apt install lld clang -y

FROM chef as planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef as builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
ENV SQLX_OFFLINE true
RUN cargo build --release
RUN cargo build --release --bin zero2prod


FROM debian:bullseye-slim AS runtime

WORKDIR /app
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends openssl ca-certificates \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/zero2prod zero2prod
COPY configuration configuration
ENV APP_ENVIRONMENT production

ENTRYPOINT ["./target/release/zero2prod"]
ENTRYPOINT ["./zero2prod"]

0 comments on commit 1999f96

Please sign in to comment.