Created
July 8, 2022 16:55
-
-
Save irwinby/1b3c0301fc9f51b788216195cb88a121 to your computer and use it in GitHub Desktop.
Dockerfile template for creating a Docker image for the Go application
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
FROM --platform=$BUILDPLATFORM golang:1.18-buster as builder | |
WORKDIR /go/src/github.com/{ORGANIZATION_NAME}/{REPOSITORY_NAME} | |
COPY go.* . | |
RUN go mod download | |
COPY . . | |
ARG TARGETOS TARGETARCH | |
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o {BINARY_NAME} main.go | |
FROM alpine:3.16.0 | |
RUN apk --no-cache add ca-certificates | |
COPY --from=builder /go/src/github.com/{ORGANIZATION_NAME}/{REPOSITORY_NAME} . | |
CMD [ "./{BINARY_NAME}" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment