FROM golang:1.23-alpine AS builder
WORKDIR /src
COPY go.mod ./
COPY go.sum* ./
COPY . .
RUN go mod tidy
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -o /out/nexavpn-api ./cmd/api

FROM alpine:3.21
WORKDIR /app
COPY --from=builder /out/nexavpn-api /usr/local/bin/nexavpn-api
COPY migrations ./migrations
COPY seed ./seed
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/nexavpn-api"]
