1.8 KiB
1.8 KiB
Task: Make Go image build resilient to mirror failures
Identity
- Task ID: 20260814-go-image-build-fix-7d4b9e2c
- Mode: Feature
- Branch: main
- Worktree: /Users/brother7/Documents/AI/NianAIGC
- Base commit:
550edcdc05 - Owner: dsh
- Status: Ready for Integration
Scope
- Fix the CI image build failure where the build machine's registry accelerator (mirror.aliyuncs.com) returned 500 on a
golang:1.21-alpineblob: make the base images overridable and add a golang-image-free build path.
Intent And Constraints
- Keep the standard multi-stage build as the default; no behavioral change for healthy registries.
- The runtime image must stay non-root, root-filesystem-read-only compatible, and identical across both build paths.
Outcome
backend/Dockerfile: addedGOLANG_IMAGEandRUNTIME_IMAGEARGs so a working mirror can be supplied via--build-argwithout editing the file.- Added
backend/Dockerfile.runtime: alpine-only image that copies a prebuilt staticzhinian-api.linuxbinary, for build environments that cannot pull the golang builder image at all. - Documented all three build paths (standard, mirror override, prebuilt binary) in
backend/README.mdanddocs/DEPLOYMENT.md.
Verification
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o zhinian-api.linux ./cmd/zhinian-apisucceeds on this machine: 12.3 MB statically linked stripped ELF x86-64, confirming the prebuilt-binary path is usable.- Docker image assembly itself must run on a machine with Docker; both Dockerfiles follow the same runtime stage as the already-merged image definition.
Follow-ups
- On the CI machine, either switch the registry accelerator in
/etc/docker/daemon.jsonor use the prebuilt-binary path. - Re-run the failing Gitea build to confirm.
Promotion Candidates
- None.