Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. ############################
  2. # STEP 1 build executable binary
  3. ############################
  4. FROM golang:alpine AS builder
  5.  
  6. # Install git.
  7. # Git is required for fetching the dependencies.
  8. RUN apk update && apk add --no-cache git
  9.  
  10. WORKDIR $GOPATH/src/mypackage/myapp/
  11. COPY . .
  12.  
  13. # Using go get.
  14. RUN go get -d -v
  15.  
  16. # Build the binary.
  17. RUN go build -o /go/bin/app
  18.  
  19. # the following command creates single static binaries that can run from scratch
  20. # RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /go/bin/app *.go
  21.  
  22. ############################
  23. # STEP 2 build a small image
  24. ############################
  25. FROM alpine:3.9
  26.  
  27. # Copy executable
  28. COPY --from=builder /go/bin/app /go/bin/app
  29.  
  30. # Run the hello binary.
  31. ENTRYPOINT ["/go/bin/app"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement