diff --git a/Cargo.lock b/Cargo.lock index 8b57022..7a5ad41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2840,7 +2840,6 @@ dependencies = [ "flate2", "poise", "protocol", - "regex", "rusqlite", "serde", "serenity", diff --git a/Dockerfile b/Dockerfile index 800c106..92ed6cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -26,7 +35,7 @@ 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 \ ./ @@ -34,3 +43,4 @@ COPY --from=build \ # 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 +