File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1
1
# ============ Build Stage ============
2
- FROM rust:1.74-bookworm as build
3
-
2
+ FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
4
3
WORKDIR /typst-bot
5
4
5
+ FROM chef AS planner
6
+
6
7
# Compilation requires only the source code.
7
8
COPY Cargo.toml Cargo.lock ./
8
9
COPY crates crates
10
+ RUN cargo chef prepare --recipe-path recipe.json
9
11
10
- RUN cargo build --release --all --config git-fetch-with-cli=true
12
+ FROM chef AS builder
11
13
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
12
21
13
22
# ============ Run Stage ============
14
23
FROM debian:bookworm-slim as run
@@ -26,11 +35,12 @@ RUN mkdir -p /bot/sqlite /bot/cache && \
26
35
touch /bot/sqlite/db.sqlite
27
36
28
37
# 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 \
30
39
/typst-bot/target/release/worker \
31
40
/typst-bot/target/release/typst-bot \
32
41
./
33
42
34
43
# Fonts are copied from the host at the very end so that the fonts can get updated without
35
44
# invalidating any previously cached image layers.
36
45
COPY fonts fonts
46
+
You can’t perform that action at this time.
0 commit comments