Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Created July 27, 2019 05:35
Show Gist options
  • Save ivancorrales/1ebdd14cc318db22824ea1f399ddbdb1 to your computer and use it in GitHub Desktop.
Save ivancorrales/1ebdd14cc318db22824ea1f399ddbdb1 to your computer and use it in GitHub Desktop.
a multi-stage build
FROM golang:1.12.5 AS ci-lint
ENV CGO_ENABLED=0 GOFLAGS="-mod=vendor"
WORKDIR /app
ADD . /app
RUN go run github.com/golangci/golangci-lint/cmd/golangci-lint run --verbose
FROM golang:1.12.5 AS ci-test_unit
ENV CGO_ENABLED=0 GOFLAGS="-mod=vendor"
WORKDIR /app
ADD . /app
RUN go test -v ./...
FROM golang:1.12.5 AS ci-build
ENV CGO_ENABLED=0 GOFLAGS="-mod=vendor"
WORKDIR /app
ADD . /app
RUN go build -o /build/demo.linux main.go
FROM golang:1.12.5
EXPOSE 3000
WORKDIR /opt/app/bin
COPY --from=ci-build /build/demo.linux ./demo
ENTRYPOINT ./demo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment