pocket-id-exporter/go/Dockerfile

29 lines
497 B
Docker
Raw Permalink Normal View History

2024-11-02 09:30:54 +01:00
# syntax=docker/dockerfile:1
# Build the application from source
FROM golang:1.20 AS build-stage
WORKDIR /app
COPY * ./
RUN go mod download
RUN CGO_ENABLED=1 GOOS=linux go build -o /main
# Run the tests in the container
FROM build-stage AS run-test-stage
RUN go test -v ./...
# Deploy the application binary into a lean image
FROM gcr.io/distroless/base-debian12 AS build-release-stage
WORKDIR /
COPY --from=build-stage /main /main
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/main"]