Skip to content

Instantly share code, notes, and snippets.

@jldeen
Created April 30, 2020 20:44
Show Gist options
  • Save jldeen/951306499dd43617f2da52f34db019c7 to your computer and use it in GitHub Desktop.
Save jldeen/951306499dd43617f2da52f34db019c7 to your computer and use it in GitHub Desktop.
Debian cgo Example Dockerfile: don't use this in production
FROM golang:1.14.2-alpine3.11 as builder
RUN apk update && apk add --no-cache git
WORKDIR $GOPATH/src/croc-hunter/
ENV GOPATH /go
COPY croc-hunter.go /go/src/croc-hunter/
COPY static/ static/
RUN go get -d -v
ENV CGO_ENABLED=0
RUN go build -o /go/bin/croc-hunter
FROM golang:1.14.2 AS final
WORKDIR /app
COPY static/ static/
COPY --from=builder /go/bin/croc-hunter /app/croc-hunter
RUN setcap 'cap_net_bind_service=+ep' /app/croc-hunter
USER 1000
EXPOSE ${PORT}
CMD ["/app/croc-hunter"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment