# syntax=docker/dockerfile:1
FROM golang:1.26-alpine AS builder

WORKDIR /app

# Install dependencies (only required ones)
COPY go.mod go.sum ./
RUN go mod download

# Build backend binary
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o formatpolice .

# Final minimal stage
FROM alpine:3.23
WORKDIR /app
COPY --from=builder /app/formatpolice .

# Expose port 8080 used by Go server
EXPOSE 8080

CMD ["./formatpolice"]