Created
July 12, 2020 12:22
-
-
Save fvosberg/27d05830c68b3e866d35bb350de3f589 to your computer and use it in GitHub Desktop.
Dockerfile for go apps with the ability to bind to port 80
This file contains hidden or 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
# Go build | |
FROM golang:1.14 as build-go | |
ARG BUILD_TAG | |
ARG BUILD_DATE | |
ENV CGO_ENABLED=0 | |
ENV GO111MODULE=on | |
ENV GOOS=linux | |
ENV GOPATH=/ | |
WORKDIR /src/ | |
COPY go.mod . | |
COPY go.sum . | |
RUN go mod download | |
COPY . . | |
RUN ./bin/build.sh --bin service | |
# Service definition | |
FROM alpine | |
RUN apk add --update libcap tzdata ca-certificates && rm -rf /var/cache/apk/* | |
COPY --from=build-go /src/service service | |
RUN setcap CAP_NET_BIND_SERVICE=+eip ./service | |
RUN update-ca-certificates | |
RUN addgroup -g 1000 -S runnergroup && adduser -u 1001 -S apprunner -G runnergroup | |
USER apprunner | |
ARG GIT_COMMIT=unknown | |
LABEL git-commit=$CI_COMMIT_SHA | |
ENTRYPOINT ["/service"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment