prop/rust/prop_grid_rs/Dockerfile
Graham McIntire 8774181824
ci: run clippy + cargo test inside Dockerfile builder
The previous approach (`docker run -v $(pwd)/rust/prop_grid_rs:/src`)
fails under act_runner because the runner container's pwd isn't a path
the host docker daemon can see — clippy installed, then cargo couldn't
find Cargo.toml.

Move the lint + test gate into the Dockerfile builder stage so the
build context ships over the socket the normal way. If clippy warns or
a test regresses, the image build fails and nothing is pushed.
2026-04-19 15:55:26 -05:00

40 lines
1.3 KiB
Docker

# syntax=docker/dockerfile:1.7
#
# Multi-arch build for `prop-grid-rs`. wgrib2 is installed from Debian
# Trixie (same version the Elixir image uses). The binary runs as a
# non-root uid that matches the fsGroup on the NFS scores mount.
FROM rust:1.94-trixie AS builder
WORKDIR /src
# Cache deps: copy manifests first so dependency changes alone don't
# invalidate the source-layer cache.
COPY Cargo.toml Cargo.lock* ./
RUN mkdir -p src src/bin \
&& echo 'fn main() {}' > src/bin/worker.rs \
&& echo '' > src/lib.rs \
&& cargo build --release --bin worker \
&& rm -rf src
COPY src ./src
COPY tests ./tests
# Lint + test gate the image build — a regressed scorer or a clippy
# warning never produces a pushable image.
RUN rustup component add clippy \
&& cargo clippy --all-targets -- -D warnings \
&& cargo test --release \
&& cargo build --release --bin worker
# Runtime image: slim debian plus wgrib2. libexpat/libjasper pulled in
# transitively by wgrib2 for PNG/JPEG2000 GRIB2 decompression.
FROM debian:trixie-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
wgrib2 \
ca-certificates \
tini \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /src/target/release/worker /usr/local/bin/prop-grid-rs
USER 65534:65534
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/prop-grid-rs"]