feat(docker): Dockerfiles agents multi-arch (amd64, arm64, armv7)

- Build en 2 étapes : rust:1.82-alpine → alpine:3.21
- Mapping automatique TARGETPLATFORM → target musl Rust
- Cache couche dépendances Cargo (builds incrémentaux rapides)
- agent-scan-network : inclut iputils (ping)
- agent-metric : inclut smartmontools (SMART), requiert --privileged pour /sys

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 06:25:43 +02:00
parent b9e3188cb4
commit df8eddc6b8
2 changed files with 74 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
# Build multi-arch : docker buildx build --platform linux/amd64,linux/arm64 .
# Note : agent-metric nécessite accès /sys et /proc — lancer avec --privileged
FROM --platform=$BUILDPLATFORM rust:1.82-alpine AS builder
ARG TARGETPLATFORM
RUN apk add --no-cache musl-dev
RUN case "$TARGETPLATFORM" in \
"linux/amd64") echo "x86_64-unknown-linux-musl" > /rust_target ;; \
"linux/arm64") echo "aarch64-unknown-linux-musl" > /rust_target ;; \
"linux/arm/v7") echo "armv7-unknown-linux-musleabihf" > /rust_target ;; \
*) echo "x86_64-unknown-linux-musl" > /rust_target ;; \
esac
RUN rustup target add "$(cat /rust_target)"
WORKDIR /build
COPY Cargo.toml ./
RUN mkdir src && echo 'fn main(){}' > src/main.rs
RUN cargo build --release --target "$(cat /rust_target)" 2>/dev/null || true
RUN rm -rf src
COPY src ./src
RUN cargo build --release --target "$(cat /rust_target)"
RUN cp "target/$(cat /rust_target)/release/agent-metric" /agent
FROM alpine:3.21
RUN apk add --no-cache ca-certificates smartmontools
WORKDIR /app
COPY --from=builder /agent ./agent-metric
EXPOSE 9101
VOLUME ["/app/config.yaml"]
# Accès /sys /proc /dev nécessaire pour les métriques — docker run --privileged
ENTRYPOINT ["./agent-metric", "/app/config.yaml"]