miroir/Dockerfile
jedarden 3e1451dff1 Multi-stage Dockerfile with musl cross-compilation and .dockerignore
Builder stage compiles both miroir-proxy and miroir-ctl as static musl
binaries, strips them, and copies into a scratch image. Updated
.cargo/config.toml to use target-feature=+crt-static instead of
incorrect CC/CFLAGS. Added .dockerignore to exclude non-essential files.

Image: 4.0 MB compressed (scratch base, single static binary).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-19 13:47:45 -04:00

26 lines
1.1 KiB
Docker

# ── Stage 1: Build static musl binaries ──────────────────────────────────────
FROM rust:1.87-slim-bookworm AS builder
RUN apt-get update && apt-get install -y musl-tools && rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/miroir
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl -p miroir-proxy -p miroir-ctl
RUN strip -s target/x86_64-unknown-linux-musl/release/miroir-proxy \
&& strip -s target/x86_64-unknown-linux-musl/release/miroir-ctl
# ── Stage 2: Scratch image with static binary ───────────────────────────────
FROM scratch
ARG VERSION=0.1.0
ARG REVISION=unknown
LABEL org.opencontainers.image.source=https://github.com/jedarden/miroir
LABEL org.opencontainers.image.version=${VERSION}
LABEL org.opencontainers.image.revision=${REVISION}
LABEL org.opencontainers.image.licenses=MIT
COPY --from=builder /usr/src/miroir/target/x86_64-unknown-linux-musl/release/miroir-proxy /miroir-proxy
EXPOSE 7700 9090
ENTRYPOINT ["/miroir-proxy"]
CMD ["--config", "/etc/miroir/config.yaml"]