Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ======================
- # GO FIRST STAGE
- # ======================
- FROM golang:latest as download
- WORKDIR /usr/src/app
- USER ${USER}
- COPY go.mod go.sum ./
- COPY . ./
- ENV GO111MODULE="on" \
- GOARCH="amd64" \
- GOCACHE="/${HOME}/.cache/go-build" \
- GOENV="/${HOME}/.config/go/env" \
- GOMODCACHE="/${HOME}/go/pkg/mod" \
- GOPATH="/${HOME}/go" \
- GOOS="linux" \
- GOTOOLDIR="/${HOME}/go/pkg/tool/linux_amd64" \
- GCCGO="gccgo" \
- CC="gcc" \
- CXX="g++" \
- CGO_ENABLED="0"
- RUN apt-get autoclean \
- && apt-get autoremove \
- && apt-get clean \
- apt-get remove
- # ======================
- # GO SECOND STAGE
- # ======================
- FROM download as utilities
- RUN apt-get update \
- && apt-get install -y \
- build-essential \
- wget \
- unzip \
- make \
- vim \
- git
- # ======================
- # GO THIRD STAGE
- # ======================
- FROM utilities as build
- WORKDIR /usr/src/app
- RUN go get -f -u -v -fix all \
- go build -o main
- COPY --from=utilities . /usr/src/app/
- # ======================
- # GO FINAL STAGE
- # ======================
- FROM alpine:latest
- COPY --from=build /usr/src/app .
- EXPOSE 3000
- CMD ["./main"]
Add Comment
Please, Sign In to add comment