-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize docker build via caching the dependencies
- Loading branch information
1 parent
cc267ce
commit f60bcf7
Showing
3 changed files
with
34 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.env | ||
target/ | ||
tests/ | ||
Dockerfile | ||
scripts/ | ||
migrations/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
FROM rust:1.72.0 | ||
|
||
FROM lukemathwalker/cargo-chef:latest-rust-1.72.0 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 | ||
|
||
|
||
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/curious_ape curious_ape | ||
COPY configuration configuration | ||
ENV APP_ENVIRONMENT production | ||
ENTRYPOINT ["./target/release/curious_ape"] | ||
ENTRYPOINT ["./curious_ape"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters