Skip to content

Commit

Permalink
Dockerfile: better cache when downloading go modules
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Nov 29, 2022
1 parent 6a7324f commit 1a562e0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ARG XX_VERSION="1.1.2"
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx

FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS base
COPY --link --from=xx / /
COPY --from=xx / /
ENV CGO_ENABLED=0
RUN apk add --no-cache file git
WORKDIR /src
Expand All @@ -40,9 +40,10 @@ RUN --mount=target=. <<EOT
EOT

FROM base as build
RUN --mount=type=bind,target=. \
RUN --mount=type=bind,source=go.mod,target=go.mod \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=cache,target=/go/pkg/mod \
go mod download
go mod download -x
ARG TARGETPLATFORM
RUN --mount=type=bind,target=. \
--mount=type=bind,from=version,source=/tmp/.ldflags,target=/tmp/.ldflags \
Expand Down

0 comments on commit 1a562e0

Please sign in to comment.