Skip to content

Instantly share code, notes, and snippets.

@starlightromero
Created July 19, 2021 19:47
Show Gist options
  • Select an option

  • Save starlightromero/0fd80e11ddcf89feaa1bc8a9331d813e to your computer and use it in GitHub Desktop.

Select an option

Save starlightromero/0fd80e11ddcf89feaa1bc8a9331d813e to your computer and use it in GitHub Desktop.
Golang Dockerfile.scratch
FROM golang:1.16-alpine as build
RUN apk add ca-certificates=20191127-r5 --no-cache
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build .
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /app/geolocation /usr/bin/geolocation
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=2 CMD curl -f http://localhost/ || exit 1
ENTRYPOINT ["/usr/bin/geolocation"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment