Skip to content

Instantly share code, notes, and snippets.

@sguzman
Created November 1, 2018 00:35
Show Gist options
  • Save sguzman/f162d286185f007fd8287a08e287bb6b to your computer and use it in GitHub Desktop.
Save sguzman/f162d286185f007fd8287a08e287bb6b to your computer and use it in GitHub Desktop.
A good image for building golang static executables then tranferring executable to alpine
FROM golang as base
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go get -u "github.com/gin-gonic/gin"
RUN go get -u "github.com/lib/pq"
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s -extldflags -static" -o main .
FROM alpine
COPY --from=base /app/main /main
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENTRYPOINT ["/main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment