Use multistage build for a fully static Docker binary build.
parent
3ea158f25a
commit
6a761c4655
13
Dockerfile
13
Dockerfile
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.10
|
||||
FROM golang:1.10 AS builder
|
||||
|
||||
RUN mkdir -p /go/src/app
|
||||
WORKDIR /go/src/app
|
||||
|
@ -7,8 +7,11 @@ ARG ROOT_IMPORT_PATH=github.com/icedream/embot
|
|||
COPY . /go/src/app
|
||||
RUN \
|
||||
mkdir -p "$GOPATH/src/$(dirname "$ROOT_IMPORT_PATH")" &&\
|
||||
ln -sf /go/src/app "$GOPATH/src/$ROOT_IMPORT_PATH" &&\
|
||||
go-wrapper download &&\
|
||||
go-wrapper install
|
||||
ln -sf "$GOPATH/src/app" "$GOPATH/src/$ROOT_IMPORT_PATH" &&\
|
||||
CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o /soccerbot "$ROOT_IMPORT_PATH"
|
||||
|
||||
CMD ["go-wrapper", "run"]
|
||||
###
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /soccerbot /
|
||||
ENTRYPOINT ["/soccerbot"]
|
||||
|
|
Loading…
Reference in New Issue