FROM golang:1.25-alpine AS builder

WORKDIR /app

RUN apk add --no-cache git curl

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

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

FROM alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /root/

COPY --from=builder /app/main .
COPY --from=builder /app/pb_public ./pb_public
COPY --from=builder /app/migrations ./migrations

EXPOSE 8090
CMD ["./main", "serve", "--dev", "--http", "0.0.0.0:8090"]
