CoreControl/agent/Dockerfile

45 lines
888 B
Docker
Raw Normal View History

2025-04-12 16:45:01 +02:00
# --- Build Stage ---
2025-04-29 21:17:21 +02:00
# Multi-Arch Builder mit expliziter Plattform-Angabe
FROM --platform=$BUILDPLATFORM golang:1.19-alpine AS builder
ARG TARGETOS TARGETARCH
2025-04-26 16:13:04 +02:00
WORKDIR /app
2025-04-29 21:17:21 +02:00
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH
2025-04-26 16:13:04 +02:00
COPY go.mod go.sum ./
RUN go mod download
COPY . .
2025-04-29 21:17:21 +02:00
# Cross-Compile für Zielarchitektur
RUN go build -ldflags="-w -s" -o app ./cmd/agent
2025-04-26 16:13:04 +02:00
# --- Run Stage ---
2025-04-29 21:17:21 +02:00
# Multi-Arch Laufzeit-Image
2025-04-26 16:13:04 +02:00
FROM alpine:latest
2025-04-29 21:17:21 +02:00
# Notwendig für TLS/SSL-Zertifikate
RUN apk --no-cache add ca-certificates gcompat
2025-04-26 16:13:04 +02:00
WORKDIR /root/
COPY --from=builder /app/app .
2025-04-29 21:17:21 +02:00
# Security Hardening
USER nobody:nobody
ENV GOMAXPROCS=1
2025-04-26 16:13:04 +02:00
CMD ["./app"]
2025-04-29 21:17:21 +02:00
# - - BUILD COMMAND - -
# docker buildx build \
# --platform linux/amd64,linux/arm64,linux/arm/v7 \
# -t haedlessdev/corecontrol-agent:1.0.0 \
# -t haedlessdev/corecontrol-agent:latest \
# --push \
# .