LINE1 10 20 30 40 50 60 70 80 901# syntax=docker/dockerfile:12#3# Three stages, one image:4# 1. client: the bun build of the Phaser client into client/dist.5# 2. builder: the Rust server, built with BuildKit cache mounts so the6# cargo registry, target/ and sccache survive between builds (same7# approach as the twig image).8# 3. runtime: slim Debian with the server binary and the built client.9#10# The server serves the client bundle itself, so there is no separate web11# server. Config is by environment: PORT, BIND_ADDRESS, STATIC_DIR.1213FROM oven/bun:1 AS client1415WORKDIR /app/client1617COPY client/package.json client/bun.lock ./18RUN --mount=type=cache,target=/root/.bun/install/cache \19 bun install --frozen-lockfile2021COPY client ./22RUN bun run build2324FROM rust:slim-bookworm AS builder2526WORKDIR /app2728# sccache caches rustc outputs across builds. Pinned, built without cloud29# backends: only the local disk cache is used.30RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \31 cargo install sccache --version 0.18.0 --locked --no-default-features --root /usr/local3233ENV CARGO_INCREMENTAL=0 \34 CARGO_NET_RETRY=10 \35 CARGO_TERM_COLOR=always \36 RUSTC_WRAPPER=sccache \37 SCCACHE_DIR=/sccache3839COPY Cargo.toml Cargo.lock ./40COPY src ./src4142# target/ lives in the cache mount, so the binary is copied out before the43# mount is released.44RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \45 --mount=type=cache,target=/app/target,sharing=locked \46 --mount=type=cache,target=/sccache,sharing=locked \47 cargo build --release --locked \48 && cp target/release/gravy /usr/local/bin/gravy \49 && sccache --show-stats5051FROM debian:bookworm-slim5253# ino reads these: the image is pushed as silenloc/gravy and deployed to54# gravy.silenlocatelli.ch through the Ino server.55LABEL remote="silenloc/gravy" \56 ino.deploy.server="https://ino.silenlocatelli.ch" \57 ino.deploy.host="gravy.silenlocatelli.ch"5859WORKDIR /app6061COPY --from=builder /usr/local/bin/gravy /app/gravy62COPY --from=client /app/client/dist /app/static6364ENV PORT=80 \65 BIND_ADDRESS=0.0.0.0 \66 STATIC_DIR=/app/static \67 RUST_LOG=info6869EXPOSE 807071ENTRYPOINT ["./gravy"]