LINE1 10 20 30 40 50 60 70 80 901# syntax=docker/dockerfile:12#3# Build strategy: BuildKit cache mounts, same as twig. The cargo registry,4# `target/` and the sccache directory persist in BuildKit cache mounts, so a5# release build reuses dependency artifacts and recompiles only local crates.6# A cold machine (fresh CI runner) pays one full dependency build.7#8# Cache mounts are local to the BuildKit daemon, and `target/` lives in the9# cache mount rather than in the image layer, so the binary is copied out of it10# within the same RUN.1112FROM rust:slim-bookworm AS builder1314# `remote` names the image for ino. The two ino.deploy labels opt this image15# into release-triggered deployment to the Once server (see README).16LABEL remote="silenloc/dial" \17 ino.deploy.server="https://ino.silenlocatelli.ch" \18 ino.deploy.host="dial.silenlocatelli.ch"1920WORKDIR /app2122# No cmake and no libssl-dev: rusqlite is built with the bundled SQLite source,23# which the image's gcc compiles. The pinned nightly ships rust-lld, and24# .cargo/config.toml links through it.25# (rust:slim-bookworm already includes gcc and libc6-dev.)2627# Install the nightly named in rust-toolchain.toml. rustup fetches it on the28# first cargo invocation in this directory, so this runs before any cargo call.29COPY rust-toolchain.toml ./30RUN cargo --version3132# sccache caches rustc outputs across builds that share the BuildKit cache.33# Pinned to a version and built without cloud backends: only the local disk34# cache is used.35RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \36 cargo install sccache --version 0.18.0 --locked --no-default-features --root /usr/local3738ENV CARGO_INCREMENTAL=0 \39 CARGO_NET_RETRY=10 \40 CARGO_TERM_COLOR=always \41 RUSTC_WRAPPER=sccache \42 SCCACHE_DIR=/sccache4344COPY Cargo.toml Cargo.lock ./45COPY .cargo ./.cargo46COPY src ./src4748RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \49 --mount=type=cache,target=/app/target,sharing=locked \50 --mount=type=cache,target=/sccache,sharing=locked \51 cargo build --release --locked \52 && cp target/release/dial /usr/local/bin/dial \53 && sccache --show-stats5455# Runtime stage56FROM debian:bookworm-slim5758WORKDIR /app5960COPY --from=builder /usr/local/bin/dial /app/dial6162# Once contract: serve HTTP on port 80, answer /up, and keep app data in63# /storage (a persistent volume that survives container replacement).64ENV DIAL_BIND=0.0.0.0:80 \65 DIAL_DB=/storage/dial.db66RUN mkdir /storage67VOLUME ["/storage"]6869EXPOSE 807071ENTRYPOINT ["./dial"]