Skip to content

Commit

Permalink
Merge pull request #23 from Tokarak/main
Browse files Browse the repository at this point in the history
Dockerfile: Use cargo-chef
  • Loading branch information
mattfbacon authored Sep 25, 2024
2 parents da4de15 + a786249 commit 6be5470
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# ============ Build Stage ============
FROM rust:1.74-bookworm as build

FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /typst-bot

FROM chef AS planner

# Compilation requires only the source code.
COPY Cargo.toml Cargo.lock ./
COPY crates crates
RUN cargo chef prepare --recipe-path recipe.json

RUN cargo build --release --all --config git-fetch-with-cli=true
FROM chef AS builder

COPY --from=planner /typst-bot/recipe.json recipe.json
# Caching layer
RUN cargo chef cook --release --workspace --recipe-path recipe.json
# Compilation requires only the source code.
COPY Cargo.toml Cargo.lock ./
COPY crates crates
RUN cargo build --release --workspace --config git-fetch-with-cli=true

# ============ Run Stage ============
FROM debian:bookworm-slim as run
Expand All @@ -26,11 +35,12 @@ RUN mkdir -p /bot/sqlite /bot/cache && \
touch /bot/sqlite/db.sqlite

# The only files we need from the build stage in order to run the bot are the two executables.
COPY --from=build \
COPY --from=builder \
/typst-bot/target/release/worker \
/typst-bot/target/release/typst-bot \
./

# Fonts are copied from the host at the very end so that the fonts can get updated without
# invalidating any previously cached image layers.
COPY fonts fonts

0 comments on commit 6be5470

Please sign in to comment.