mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-17 15:36:50 +00:00
45 lines
888 B
Docker
45 lines
888 B
Docker
# --- Build Stage ---
|
|
# Multi-Arch Builder mit expliziter Plattform-Angabe
|
|
FROM --platform=$BUILDPLATFORM golang:1.19-alpine AS builder
|
|
|
|
ARG TARGETOS TARGETARCH
|
|
|
|
WORKDIR /app
|
|
|
|
ENV GO111MODULE=on \
|
|
CGO_ENABLED=0 \
|
|
GOOS=$TARGETOS \
|
|
GOARCH=$TARGETARCH
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
|
|
# Cross-Compile für Zielarchitektur
|
|
RUN go build -ldflags="-w -s" -o app ./cmd/agent
|
|
|
|
# --- Run Stage ---
|
|
# Multi-Arch Laufzeit-Image
|
|
FROM alpine:latest
|
|
|
|
# Notwendig für TLS/SSL-Zertifikate
|
|
RUN apk --no-cache add ca-certificates gcompat
|
|
|
|
WORKDIR /root/
|
|
|
|
COPY --from=builder /app/app .
|
|
|
|
# Security Hardening
|
|
USER nobody:nobody
|
|
ENV GOMAXPROCS=1
|
|
|
|
CMD ["./app"]
|
|
|
|
# - - 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 \
|
|
# . |