FROM golang:1.23-alpine AS builder
WORKDIR /app

# Dependencies are pinned in go.mod/go.sum, so the build is reproducible and
# needs no module resolution at image-build time.
COPY go.mod go.sum ./
RUN go mod download

COPY main.go .
# The admin UI is embedded from web/ via //go:embed, so it must exist at build time.
COPY web ./web
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o mildgrim-drop main.go

FROM alpine:3.20
RUN apk add --no-cache ca-certificates mailcap
WORKDIR /app
COPY --from=builder /app/mildgrim-drop /app/mildgrim-drop
EXPOSE 8095
ENTRYPOINT ["/app/mildgrim-drop"]
