Reuse go docker build cache (#1218)
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
FROM alpine:3.10 as base
|
||||
RUN apk add --update ca-certificates
|
||||
|
||||
FROM golang:1.11-alpine as builder
|
||||
RUN apk add bash ca-certificates git gcc g++ libc-dev
|
||||
|
||||
@@ -11,15 +14,28 @@ ARG BUILDDATE=unknown
|
||||
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
ARG GOPKG=github.com/fission/fission
|
||||
COPY . /go/src/${GOPKG}
|
||||
|
||||
ENV GO111MODULE=on
|
||||
|
||||
WORKDIR /go/src/${GOPKG}
|
||||
|
||||
# To reuse build cache, copy go.mod & go.sum and download dependencies first.
|
||||
COPY go.* ./
|
||||
|
||||
RUN go mod download
|
||||
|
||||
# Copy whole fission directory to work dir
|
||||
COPY ./ ./
|
||||
|
||||
WORKDIR /go/src/${GOPKG}/cmd/fetcher
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-o /go/bin/fetcher \
|
||||
-gcflags=-trimpath=$GOPATH \
|
||||
-asmflags=-trimpath=$GOPATH \
|
||||
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
|
||||
|
||||
FROM alpine:3.4
|
||||
FROM base
|
||||
COPY --from=builder /go/bin/fetcher /
|
||||
EXPOSE 8000
|
||||
|
||||
|
||||
Reference in New Issue
Block a user