Skip to content

fix(docker): copy go.sum so the server image builds#53

Open
qiansheng91 wants to merge 1 commit into
mainfrom
fix/docker-build-missing-gosum
Open

fix(docker): copy go.sum so the server image builds#53
qiansheng91 wants to merge 1 commit into
mainfrom
fix/docker-build-missing-gosum

Conversation

@qiansheng91

Copy link
Copy Markdown
Collaborator

Problem

deployments/docker/Dockerfile copies only go.mod into the build stage:

COPY go.mod ./

go.sum is therefore absent from the build context, and go build fails:

internal/umodel/schemaspec/registry.go:11:2: missing go.sum entry for module providing package gopkg.in/yaml.v3 (imported by github.com/alibaba/UnifiedModel/internal/umodel); to add:
	go get github.com/alibaba/UnifiedModel/internal/umodel

Fix

Copy go.sum alongside go.mod and pre-download modules before building — the standard multi-stage Go pattern:

COPY go.mod go.sum ./
RUN go mod download

go.sum already exists at the repo root, so it just needs to be added to the COPY.

Verification

Built with the build context = repo root (docker build -f deployments/docker/Dockerfile .):

  • Before (original Dockerfile): fails at go build with the missing go.sum entry error above.
  • After (this change): image builds successfully through both stages.

deployments/docker/Dockerfile copied only go.mod into the build stage,
so `go build` failed with:

  missing go.sum entry for module providing package gopkg.in/yaml.v3
  (imported by github.com/alibaba/UnifiedModel/internal/umodel)

Copy go.sum alongside go.mod and run `go mod download` before building,
the standard multi-stage Go pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant