1+ # syntax=docker/dockerfile:1.6
12# ---- Builder stage ----
23# Compiles the React frontend and the Rust binary with the frontend embedded.
34FROM rust:bookworm AS builder
@@ -21,11 +22,20 @@ WORKDIR /build
2122# 1. Fetch and cache Rust dependencies.
2223# cargo fetch needs a valid target, so we create stubs that get replaced later.
2324COPY Cargo.toml Cargo.lock ./
24- RUN mkdir src && echo "fn main() {}" > src/main.rs && touch src/lib.rs && cargo fetch && rm -rf src
25+ RUN --mount=type=cache,target=/usr/local/cargo/registry \
26+ --mount=type=cache,target=/usr/local/cargo/git \
27+ --mount=type=cache,target=/build/target \
28+ mkdir src && echo "fn main() {}" > src/main.rs && touch src/lib.rs \
29+ && cargo build --release \
30+ && rm -rf src
2531
2632# 2. Build the frontend.
33+ COPY interface/package.json interface/
34+ RUN --mount=type=cache,target=/root/.bun/install/cache \
35+ cd interface && bun install
2736COPY interface/ interface/
28- RUN cd interface && bun install && bun add -d @rollup/rollup-linux-x64-gnu && bun run build
37+ RUN --mount=type=cache,target=/root/.bun/install/cache \
38+ cd interface && bun run build
2939
3040# 3. Copy source and compile the real binary.
3141# build.rs runs the frontend build (already done above, node_modules present).
@@ -35,7 +45,10 @@ COPY build.rs ./
3545COPY prompts/ prompts/
3646COPY migrations/ migrations/
3747COPY src/ src/
38- RUN cargo build --release
48+ RUN --mount=type=cache,target=/usr/local/cargo/registry \
49+ --mount=type=cache,target=/usr/local/cargo/git \
50+ --mount=type=cache,target=/build/target \
51+ SPACEBOT_SKIP_FRONTEND_BUILD=1 cargo build --release
3952
4053# ---- Slim stage ----
4154# Minimal runtime with just the binary. No browser.
0 commit comments