picture-uploader/go/Dockerfile

29 lines
500 B
Docker
Raw Permalink Normal View History

2024-02-08 10:22:58 +01:00
# syntax=docker/dockerfile:1
# Build the application from source
2024-03-08 14:22:02 +01:00
FROM golang:1.20.10 AS build-stage
2024-02-08 10:22:58 +01:00
WORKDIR /app
2024-03-08 14:22:02 +01:00
COPY * ./
2024-02-08 10:22:58 +01:00
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -o /main
2024-01-11 22:23:10 +01:00
# 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-debian11 AS build-release-stage
WORKDIR /
2024-02-08 10:22:58 +01:00
COPY --from=build-stage /main /main
2024-01-11 22:23:10 +01:00
EXPOSE 8080
USER nonroot:nonroot
2024-02-08 10:22:58 +01:00
ENTRYPOINT ["/main"]