Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############################
- # STEP 1 build executable binary
- ############################
- FROM golang:alpine AS builder
- # Install git.
- # Git is required for fetching the dependencies.
- RUN apk update && apk add --no-cache git
- WORKDIR $GOPATH/src/mypackage/myapp/
- COPY . .
- # Using go get.
- RUN go get -d -v
- # Build the binary.
- RUN go build -o /go/bin/app
- # the following command creates single static binaries that can run from scratch
- # RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /go/bin/app *.go
- ############################
- # STEP 2 build a small image
- ############################
- FROM alpine:3.9
- # Copy executable
- COPY --from=builder /go/bin/app /go/bin/app
- # Run the hello binary.
- ENTRYPOINT ["/go/bin/app"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement