Skip to content

Commit

Permalink
build: cache go mod (#345)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
blakepettersson authored Sep 22, 2023
1 parent b5926d7 commit fbfb7b1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fbfb7b1

Please sign in to comment.