FROM golang:1.17 as builder
LABEL stage=builder

WORKDIR /server/app

COPY paid-order/go.mod paid-order/go.sum ./
COPY infrastructure/. ../infrastructure/
RUN go mod download
COPY ./paid-order .

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app ./cmd/app

FROM alpine:latest
RUN apk add --no-cache curl tzdata
WORKDIR /server
COPY --from=builder /server/app .
ENTRYPOINT ["/server/app"]
CMD ["run"]
