Skip to content

Commit

Permalink
Update .dockerignore and Dockerfile to include/exclude specific files…
Browse files Browse the repository at this point in the history
… and directories for Docker image building and deployment.
  • Loading branch information
josemoura212 committed Jun 9, 2024
1 parent dce7266 commit cb0dffb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
10 changes: 9 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
**/target
.env
.dockerignore
spec.yaml
target/
deploy/
tests/
Dockerfile
scripts/
migrations/
28 changes: 25 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
FROM rust:latest
FROM lukemathwalker/cargo-chef:latest-rust-1.78.0 as chef
WORKDIR /app
RUN apt update && apt install lld clang -y

FROM chef as planner
COPY . .
# Compute a lock-like file for our project
RUN cargo chef prepare --recipe-path recipe.json

FROM chef as builder
COPY --from=planner /app/recipe.json recipe.json
# Build our project dependencies, not our application!
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
ENV SQLX_OFFLINE true
RUN cargo build --release
# Build our project
RUN cargo build --release --bin zero2prod

FROM debian:bookworm-slim AS runtime
WORKDIR /app
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 configuration configuration
ENV APP_ENVIRONMENT production
ENTRYPOINT ["./target/release/zero2prod"]
ENTRYPOINT ["./zero2prod"]

0 comments on commit cb0dffb

Please sign in to comment.