Skip to content

Instantly share code, notes, and snippets.

@chrisDeFouRire
Last active February 23, 2018 23:14
Show Gist options
  • Save chrisDeFouRire/d4a6df08a98263c15ba5cb5bf50ee8ac to your computer and use it in GitHub Desktop.
Save chrisDeFouRire/d4a6df08a98263c15ba5cb5bf50ee8ac to your computer and use it in GitHub Desktop.
FROM golang:1.10-alpine3.7 as builder
ARG BUILD
ARG TAG
WORKDIR /go/src/app
RUN apk update && apk add curl && apk add git
RUN curl https://glide.sh/get | sh
COPY glide.yaml .
COPY glide.lock .
RUN glide install
COPY . .
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.Build=$BUILD -X main.Tag=$TAG" -o Main
FROM alpine:3.7
# add ca-certificates in case you need them
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
# set working directory
WORKDIR /root
# copy the binary from builder
COPY --from=builder /go/src/app/Main .
# run the binary
CMD ["/root/Main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment