Files
faunosteo/crates/worker/Dockerfile
T

38 lines
1.9 KiB
Docker

# syntax=docker/dockerfile:1.7
# Faunosteo worker image (review Part IV, VIII.1). Build context = repository root:
# docker build -f crates/worker/Dockerfile --target test . # sandbox tests + seccomp derivation
# docker build -f crates/worker/Dockerfile -t faunosteo_worker:dev . # runtime image
# The binary is a static musl executable; the runtime image carries nothing else.
FROM rust:1.99.0-alpine3.24 AS base
# build-base: the C compiler for libwebp (libwebp-sys, D-R4), nothing else is compiled from C.
# rustfmt/clippy: listed in rust-toolchain.toml, absent from the image's minimal profile.
RUN apk add --no-cache build-base && rustup component add rustfmt clippy
WORKDIR /w
COPY Cargo.toml Cargo.lock rust-toolchain.toml rustfmt.toml clippy.toml ./
COPY .cargo .cargo
COPY crates crates
FROM base AS build
RUN --mount=type=cache,id=faunosteo_cargo_registry_musl,target=/usr/local/cargo/registry \
--mount=type=cache,id=faunosteo_target_musl,target=/w/target \
cargo build -p faunosteo-worker --release --locked \
&& cp target/release/faunosteo-worker /faunosteo-worker
# The tests run against the musl binary that ships, inside the default Docker seccomp
# profile (the inner filter is allowed by it). strace serves the allowlist derivation.
FROM base AS test
RUN apk add --no-cache strace
RUN --mount=type=cache,id=faunosteo_cargo_registry_musl,target=/usr/local/cargo/registry \
--mount=type=cache,id=faunosteo_target_musl,target=/w/target \
cargo test -p faunosteo-worker --features test-hooks --locked -- --test-threads=4
RUN --mount=type=cache,id=faunosteo_cargo_registry_musl,target=/usr/local/cargo/registry \
--mount=type=cache,id=faunosteo_target_musl,target=/w/target \
sh crates/worker/scripts/derive-seccomp.sh
FROM gcr.io/distroless/static-debian12:nonroot AS runtime
COPY --from=build /faunosteo-worker /faunosteo-worker
USER nonroot
ENTRYPOINT ["/faunosteo-worker"]
CMD ["run", "--check"]