# Build stage — cross-compile for Windows amd64
FROM golang:1.25-alpine AS builder

WORKDIR /src
COPY go.mod ./
# No external dependencies yet — no go.sum needed
COPY . .

# Produce a static Windows binary
RUN GOOS=windows GOARCH=amd64 CGO_ENABLED=0 \
    go build -mod=mod -trimpath -ldflags="-s -w" \
    -o /out/flatrender-node-agent.exe \
    ./cmd/agent

# ── Output stage ───────────────────────────────────────────────────────────────
# For dev/CI use only — the production binary is copied to Windows render nodes.
FROM scratch
COPY --from=builder /out/flatrender-node-agent.exe /flatrender-node-agent.exe
ENTRYPOINT ["/flatrender-node-agent.exe"]
