FROM golang:1.25.8-alpine3.23 AS base
WORKDIR /app
RUN apk add --no-cache git make

FROM base AS dev
RUN go install github.com/air-verse/air@latest
COPY go.mod go.sum ./
RUN go mod download
CMD ["air", "-c", ".air.toml"]

FROM base AS builder
COPY . .
RUN go build -o /bin/server ./cmd/server

FROM alpine:3.23 AS prod
RUN apk add --no-cache ca-certificates
COPY --from=builder /bin/server /bin/server
EXPOSE 8080
CMD ["/bin/server"]
