Currently, only one CI build can be started at the same time due to we only have only one testing cluster. This PR aims to enable multiple concurrent builds can be triggered to reduce the waiting time for CI builds. The major changes listed below: 1. Each build generate unique images for testing and debugging 2. Check whether the testing cluster is being used by another build. 3. Cache docker image & go mod after build finished 4. Improve dockerfiles for reusing docker build cache
43 lines
1.1 KiB
Docker
43 lines
1.1 KiB
Docker
FROM alpine:3.10 as base
|
|
RUN apk add --update ca-certificates
|
|
|
|
FROM golang:1.11-alpine as fission-builder
|
|
RUN apk add bash ca-certificates git gcc g++ libc-dev
|
|
|
|
ARG GOPKG=github.com/fission/fission
|
|
|
|
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/builder
|
|
|
|
ARG GITCOMMIT=unknown
|
|
# E.g. GITCOMMIT=$(git rev-parse HEAD)
|
|
|
|
ARG BUILDVERSION=unknown
|
|
# E.g. BUILDVERSION=$(git rev-parse HEAD)
|
|
|
|
ARG BUILDDATE=unknown
|
|
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
|
-o /go/bin/builder \
|
|
-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 base
|
|
COPY --from=fission-builder /go/bin/builder /
|
|
EXPOSE 8001
|
|
|
|
ENTRYPOINT ["/builder"]
|