------ > [goversioninfo 1/1] RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg/mod GOBIN=/out GO111MODULE=on go install "github.com/josephspurrier/goversioninfo@v1.3.0": 21.45 go: github.com/josephspurrier/goversioninfo@v1.3.0: github.com/josephspurrier/goversioninfo@v1.3.0: Get "https://proxy.golang.org/github.com/josephspurrier/goversioninfo/@v/v1.3.0.info": dial tcp 142.251.42.241:443: connect: connection refused ------ Dockerfile:41 -------------------- 40 | ARG GOVERSIONINFO_VERSION 41 | >>> RUN --mount=type=cache,target=/root/.cache/go-build \ 42 | >>> --mount=type=cache,target=/go/pkg/mod \ 43 | >>> GOBIN=/out GO111MODULE=on go install "github.com/josephspurrier/goversioninfo@${GOVERSIONINFO_VERSION}" 44 | #GOBIN=/out GO111MODULE=on go install "github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION}" -------------------- ERROR: failed to solve: process "/bin/sh -c GOBIN=/out GO111MODULE=on go install \"github.com/josephspurrier/goversioninfo@${GOVERSIONINFO_VERSION}\"" did not complete successfully: exit code: 1
Upon reviewing the error output, the issue was traced to line 41 of the Dockerfile. It was discovered that access to the goproxy was denied. To resolve this issue, an environment variable was added, redirecting to a local proxy.
1 2 3 4 5 6 7 8
# /dockerfile # ... FROM build-base-${BASE_VARIANT} AS goversioninfo ARG GOVERSIONINFO_VERSION RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ GOBIN=/out GO111MODULE=on GOPROXY=https://goproxy.cn,direct go install "github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION}" #GOBIN=/out GO111MODULE=on go install "github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION}"