Skip to content

Commit

Permalink
Merge pull request #8 from crazy-max/fix-dockerfile
Browse files Browse the repository at this point in the history
Dockerfile: better cache when downloading go modules
  • Loading branch information
crazy-max authored Nov 29, 2022
2 parents 6a7324f + 1a562e0 commit 2b9d4d6
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 2b9d4d6

Please sign in to comment.