FROM golang:1.22-alpine AS build
WORKDIR /src
COPY shared/ shared/
COPY gateway/go.mod gateway/go.sum gateway/
WORKDIR /src/gateway
RUN go mod download
COPY gateway/ .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /gateway .

FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /gateway /gateway
EXPOSE 8080
USER 65534
ENTRYPOINT ["/gateway"]
