5.2 KiB
5.2 KiB
Task: Diagnose Go module download timeout during Docker build
Identity
- Task ID: 20260815-go-mod-download-timeout-5b8e2c
- Mode: Feature
- Branch: main
- Worktree: D:\Datas\OthersProjects\NianAIGC
- Base commit:
9f40162c6b - Owner: codex
- Status: Ready for Integration
Scope
- Diagnose the Jenkins Docker build failure at
backend/Dockerfile:20without changing application or deployment code. - Verify whether
github.com/jackc/pgpassfile@v1.0.0is invalid or whether the failure is limited to dependency-network access. - Identify the repository-supported build path for China-hosted CI and provide a target-environment verification command.
- Make the standard Go Docker build use a China-reachable, integrity-checked module source by default while allowing CI to override it.
- Diagnose and fix the root Next.js image's
npm ciregistry timeout using a free mirror without changing dependency versions.
Intent And Constraints
- Treat the supplied Jenkins log as the production-environment failure artifact and keep confirmed repository facts separate from target-network assumptions.
- Keep the implementation surgical: change only the standard Go Docker build configuration and its task record; Jenkins configuration is outside this repository.
- Do not weaken module integrity checks (
go.sum/GOSUMDB) to work around a transport timeout. - Keep the package lockfile authoritative; do not regenerate dependency versions merely to change registry routing.
Outcome
- The failure occurs before compilation while the standard
backend/Dockerfilerunsgo mod download; its build stage has noGOPROXYoverride and therefore attemptedhttps://proxy.golang.org. - The failing module is a valid indirect dependency of
github.com/jackc/pgx/v5@v5.5.5, and both its module and checksum entries are present. - A cold download of the failing module and then the complete module set succeeded through
https://goproxy.cn,direct; the individual fetch completed in 0.18 seconds and the complete set in 1 second in the diagnostic environment. - The repository already supplies
backend/Dockerfile.alpineas the recommended China-CI build. It uses the Aliyun Alpine package mirror,GOPROXY=https://goproxy.cn,direct, andGOSUMDB=sum.golang.google.cn. - Updated the standard
backend/Dockerfileto use the same integrity-checked Go module endpoints by default and exposeGOPROXY/GOSUMDBas build arguments for internal or global proxy overrides. - The later Jenkins failure was a separate root-image issue:
npm ciused the default npm registry and ran for 1769 seconds before npm reportedExit handler never called. - Updated the root
Dockerfiledeps stage to use the freehttps://registry.npmmirror.commirror by default, exposeNPM_REGISTRYas a build argument, add bounded retries/timeouts, and skip audit/fund network calls. The package lockfile and dependency versions were not changed. - An initial
--replace-registry-host=alwaysexperiment was rejected because 16 lockfile entries point to Tencent's/npm/...tarball paths, which do not map to the npmmirror path layout; the retained command only sets--registryand leaves those explicit URLs intact. - No application, deployment manifest, dependency, checksum, or CI file was changed.
Verification
- Confirmed that the supplied
Dockerfile:20location matchesbackend/Dockerfileand thatbackend/Dockerfile.alpineplaces its module download at line 17. - Ran a fresh-cache
go mod download -x github.com/jackc/pgpassfile@v1.0.0throughgoproxy.cn: exit 0. - Ran a fresh-cache full
go mod downloadthroughgoproxy.cn: exit 0. - Confirmed with
go mod graphthatpgx/v5@v5.5.5depends onpgpassfile@v1.0.0. - Static Dockerfile contract check passed: both proxy arguments and their environment bindings precede
RUN go mod download. go test ./...passed for all 19 Go packages, andgo vet ./...passed.- Re-ran a fresh-cache full module download using the new defaults: exit 0.
- Ran
go mod verify: all downloaded modules verified. - Ran a fresh-cache root
npm ciwith the Dockerfile's registry, retry, timeout,--no-audit, and--no-fundoptions: exit 0 in 15.29 seconds. - Confirmed the root lockfile contains 241
registry.npmjs.orgentries and 16 explicit Tencent mirror entries; no lockfile rewrite was performed. - Could not run a full Docker image build because the local Docker Desktop Linux daemon is unavailable; the Jenkins-node rerun remains the authoritative end-to-end check.
Follow-ups
- Re-run the existing standard Docker build on the Jenkins agent;
backend/Dockerfile.alpineremains the more self-contained fallback when Alpine package downloads also need an Aliyun mirror. - If that command still times out, test HTTPS egress/DNS from the Jenkins Docker build network to
mirrors.aliyun.com,goproxy.cn, andsum.golang.google.cn, or use the organization's internal Go module proxy. - Re-run the root image build on Jenkins with
docker build --progress=plain --no-cache -t <image> .; if it still fails, capture the first failing package URL because the lockfile has explicit Tencent mirror URLs for a small subset of packages.
Promotion Candidates
- None recorded.