FROM golang:1.24 as build

WORKDIR /app

# Copy module files and download dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy the rest of the application source and build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /invoiceapi cmd/invoiceapi/main.go

EXPOSE 8080

FROM alpine:3
# the test program:
COPY --from=build /invoiceapi /invoiceapi
# the tls certificates:
# NB: this pulls directly from the upstream image, which already has ca-certificates:

CMD [ "/invoiceapi" ]

