FROM --platform=$BUILDPLATFORM golang:alpine AS builderWORKDIR /appCOPY ../go.mod ../go.sum ./RUN go mod download# Copy source filesCOPY . ./# BuildARG TARGETOS TARGETARCHRUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-w -s" -o /agent ./internal/cmd/agent# --------------------------# Final image# Note: must cap_add: [CAP_PERFMON] and mount /dev/dri/ as volume# --------------------------FROM alpine:3.24COPY --from=builder /agent /agentRUN apk add --no-cache -X https://dl-cdn.alpinelinux.org/alpine/edge/testing igt-gpu-tools nvtop smartmontools zfs# Ensure data persistence across container recreationsVOLUME ["/var/lib/beszel-agent"]ENTRYPOINT ["/agent"]