# stage 1: build golang backend
FROM golang:1.21-alpine3.19 as go-builder

WORKDIR /go-builder
COPY . .

RUN \
    go mod download && \
    go mod verify && \
    go build -v -ldflags "-s -w" -o products-app ./app/main.go


# stage 2: build final container
FROM alpine:3.19

WORKDIR /app
COPY --from=go-builder /go-builder/products-app /app

USER 33

ENTRYPOINT ["/app/products-app"]
