-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 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 @@ | ||
/target |
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,45 @@ | ||
# Leveraging the pre-built Docker images with | ||
# cargo-chef and the Rust toolchain | ||
# https://www.lpalmieri.com/posts/fast-rust-docker-builds/ | ||
FROM --platform=${BUILDPLATFORM:-linux/amd64} lukemathwalker/cargo-chef:latest-rust-1.63.0 AS chef | ||
WORKDIR /coach | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef as builder | ||
|
||
WORKDIR /coach | ||
|
||
COPY --from=planner /coach/recipe.json recipe.json | ||
|
||
RUN apt-get update && apt-get install -y clang cmake && rustup component add rustfmt | ||
|
||
# Build dependencies - this is the caching Docker layer! | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
|
||
COPY . . | ||
|
||
# Build actual target here | ||
RUN cargo build --release | ||
|
||
RUN mv target/release/coach /coach/coach | ||
|
||
FROM debian:11-slim | ||
ARG APP=/coach | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y ca-certificates tzdata \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV TZ=Etc/UTC \ | ||
RUN_MODE=production | ||
|
||
RUN mkdir -p ${APP} | ||
|
||
COPY --from=builder /coach/coach ${APP}/coach | ||
|
||
WORKDIR ${APP} | ||
|
||
CMD ["./coach"] |