# Load golang image FROM golang:1.21-alpine as builder RUN apk add make ARG VERSION=undefined WORKDIR /go/src/app # Set our build environment ENV GOCACHE=/tmp/.go-build-cache # This variable communicates to the service that it's running inside # a docker container. ENV ENV_DOCKER=true # Copy dockerignore files COPY .dockerignore ./ # Install go deps using the cache COPY go.mod go.sum ./ RUN --mount=type=cache,target=/tmp/.go-build-cache \ go mod download -x COPY Makefile ./ # Copy source files COPY main.go ./ # Build it RUN --mount=type=cache,target=/tmp/.go-build-cache \ make backend VERSION=$VERSION # Now create a new image with just the binary FROM gcr.io/distroless/static-debian11:nonroot WORKDIR /app # Set our runtime environment ENV ENV_DOCKER=true COPY --from=builder /go/src/app/finger /usr/local/bin/finger HEALTHCHECK CMD [ "finger", "healthcheck" ] EXPOSE 8080 ENTRYPOINT [ "finger" ] CMD [ "serve" ]