Skip to content

Instantly share code, notes, and snippets.

@tobiassjosten
Created December 25, 2023 17:18
Show Gist options
  • Save tobiassjosten/83ca1d5755396be1b704143d929302fb to your computer and use it in GitHub Desktop.
Save tobiassjosten/83ca1d5755396be1b704143d929302fb to your computer and use it in GitHub Desktop.
Docker setup for Go app
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