# ── Build stage ──────────────────────────────────────────────────────────────
FROM golang:1.22-alpine AS builder

WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /isosilo .

# ── Runtime stage ─────────────────────────────────────────────────────────────
FROM scratch

COPY --from=builder /isosilo /isosilo

# ISOs should be mounted here at runtime.
VOLUME ["/isos"]

EXPOSE 8080
ENTRYPOINT ["/isosilo", "-dir", "/isos", "-addr", ":8080"]
