Skip to content

Instantly share code, notes, and snippets.

@kokoichi206
Last active November 23, 2023 06:15
Show Gist options
  • Save kokoichi206/954c4d7f144307c460ea5143528a5a38 to your computer and use it in GitHub Desktop.
Save kokoichi206/954c4d7f144307c460ea5143528a5a38 to your computer and use it in GitHub Desktop.
golang dockerfile
# syntax=docker/dockerfile:1
# 1. build
FROM golang:1.21-alpine AS build
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY *.go ./
RUN go build -o /api
# 2. deploy
FROM gcr.io/distroless/base-debian10
WORKDIR /
COPY --from=build /api /api
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/api"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment