Skip to content

Commit

Permalink
add docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
agourlay committed Nov 18, 2022
1 parent 067901d commit b5b9a94
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
45 changes: 45 additions & 0 deletions Dockerfile
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"]

0 comments on commit b5b9a94

Please sign in to comment.