Skip to content

Instantly share code, notes, and snippets.

@lfaoro
Created October 12, 2018 22:58
Show Gist options
  • Save lfaoro/b2cb6feeedeaa9c3151372b881520f48 to your computer and use it in GitHub Desktop.
Save lfaoro/b2cb6feeedeaa9c3151372b881520f48 to your computer and use it in GitHub Desktop.
Compile multiple Go programs and load them all in a light container
FROM golang:alpine as builder
WORKDIR /build
COPY . .
RUN apk update && apk upgrade && \
apk add git gcc
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go install -gcflags "-N -l" ./cmd/...
FROM alpine:latest
RUN apk update && apk add ca-certificates && \
rm -rf /var/cache/apk/*
COPY --from=builder /go/bin/ /usr/local/bin/
COPY --from=builder /build/static/ /usr/local/bin/static/
WORKDIR /usr/local/bin/
CMD ["server", "-hostPort", ":8080", "-devel=false"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment