Created
December 25, 2023 17:18
-
-
Save tobiassjosten/83ca1d5755396be1b704143d929302fb to your computer and use it in GitHub Desktop.
Docker setup for Go app
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 golang:1.21-alpine as compiler | |
ARG DOCKER_GIT_CREDENTIALS_GITHUB | |
ENV CGO_ENABLED=0 | |
COPY . /tmp/src | |
WORKDIR /tmp/src | |
RUN apk --no-cache add git~=2 ca-certificates~=20230506 && \ | |
echo ${DOCKER_GIT_CREDENTIALS_GITHUB} >> ~/.git-credentials && \ | |
git config --global credential.helper store && \ | |
go build -o /tmp/app . | |
FROM scratch | |
COPY --from=compiler /tmp/app / | |
COPY --from=compiler /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | |
EXPOSE 8080 | |
ENTRYPOINT ["/app"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment