Hi everyone!
I am currently trying to build a docker image based on windows server core to use a program written in golang. At the moment I am stuck in the step “go mod vendor” due to the download of the required go packages not being downloaded.
Error:
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; go mod vendor' returned a non-zero code: 1
Example of the error output of a package:
helm.sh/helm/v3/pkg/time: helm.sh/helm/v3@v3.9.4: Get "https://proxy.golang.org/helm.sh/helm/v3/@v/v3.9.4.zip": dial tcp: lookup proxy.golang.org: getaddrinfow: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server.
The beginning of my dockefile: Error happens in the second step “go mod vendor”
FROM golang:1.19.0-windowsservercore-ltsc2022 as build_env
# Copy the source from the current directory to the Working Directory inside the container
WORKDIR /app
ENV GOPRIVATE=github.com/Company/*
ARG VERSION="development"
ARG COMMIT="NOCOMMIT"
ARG SENTRY_DSN=""
ARG DESCRIPTIONS_URL=""
ARG TARGETOS
ARG TARGETARCH
# Copy go mod and sum files
COPY go.mod go.sum ./
# Get dependancies - will also be cached if we won't change mod/sum
RUN go mod vendor
# COPY the source code as the last step
COPY . .
# Build the Go app
#-ldflags "-s -X github.com/Company/internal/constants.Version=${VERSION} -X github.com/Company/internal/constants.SCMCommit=${COMMIT} -X github.com/Company/internal/constants.SentryDSN=${SENTRY_DSN} -X github.com/Company/internal/constants.BaseURL=${DESCRIPTIONS_URL}" \
RUN go mod vendor
RUN go build \
-a -installsuffix cgo \
-o bin/abc cmd/console/main.go
USER Company
Anyone can help?
Thanks in advance!