Skip to content

Commit 6be5470

Browse files
authored
Merge pull request #23 from Tokarak/main
Dockerfile: Use cargo-chef
2 parents da4de15 + a786249 commit 6be5470

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
# ============ Build Stage ============
2-
FROM rust:1.74-bookworm as build
3-
2+
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
43
WORKDIR /typst-bot
54

5+
FROM chef AS planner
6+
67
# Compilation requires only the source code.
78
COPY Cargo.toml Cargo.lock ./
89
COPY crates crates
10+
RUN cargo chef prepare --recipe-path recipe.json
911

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

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

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

2837
# The only files we need from the build stage in order to run the bot are the two executables.
29-
COPY --from=build \
38+
COPY --from=builder \
3039
/typst-bot/target/release/worker \
3140
/typst-bot/target/release/typst-bot \
3241
./
3342

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

0 commit comments

Comments
 (0)