# Stage 1: Build the Go binary FROM golang:1.26-alpine AS builder RUN apk add --no-cache gcc musl-dev # for go-sqlite3 (CGO) WORKDIR /build COPY go.mod go.sum ./ RUN go mod download COPY . . RUN CGO_ENABLED=1 go build -o /app/server ./cmd/web # Stage 2: Minimal runtime image FROM alpine:latest RUN apk --no-cache add ca-certificates tzdata WORKDIR /app COPY --from=builder /app/server /app/server COPY --from=builder /build/config /app/config COPY --from=builder /build/public /app/public RUN mkdir -p /app/dbs /app/uploads EXPOSE 8000 CMD ["/app/server"]