1
0
Fork 0
mirror of https://github.com/kyverno/policy-reporter.git synced 2024-12-14 11:57:32 +00:00

build: cache go mod (#345)

For local development, to remove the step where go modules are
downloaded on every `docker build`, first copy only `go.mod` and
`go.sum` to the Docker workspace.

This step only needs to be performed whenever one of those files
changes.

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This commit is contained in:
Blake Pettersson 2023-09-22 13:29:01 +02:00 committed by GitHub
parent b5926d7d98
commit fbfb7b1a11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,15 +4,14 @@ ARG LD_FLAGS='-s -w -linkmode external -extldflags "-static"'
ARG TARGETPLATFORM
WORKDIR /app
COPY . .
RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)
RUN go env
COPY go.* ./
RUN go env && go mod download
RUN go get -d -v \
&& go install -v
COPY . .
RUN CGO_ENABLED=1 go build -ldflags="${LD_FLAGS}" -tags="sqlite_unlock_notify" -o /app/build/policyreporter -v