Last active
November 23, 2023 06:15
-
-
Save kokoichi206/954c4d7f144307c460ea5143528a5a38 to your computer and use it in GitHub Desktop.
golang dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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