opea-project / GenAIInfra

Containerization and cloud native suite for OPEA
Apache License 2.0
30 stars 59 forks source link

Can't build GMC image due to go mod download failure #367

Open weichengintel opened 2 months ago

weichengintel commented 2 months ago

I'm trying to set up GMC (GenAI Microservices Connector) following the instructions in the README, but I'm encountering an error during the Docker image build process. Specifically, I can't download the Go modules while building the Docker image.

Steps to Reproduce

cd GenAIInfra/microservices-connector
make build
make docker.build

Error Message

Building manager Docker image...
docker build -t docker.io/opea/gmcmanager:latest -f Dockerfile.manager .
[+] Building 31.7s (11/16)                                                                                         docker:default
 => [internal] load build definition from Dockerfile.manager                                                                 0.0s
 => => transferring dockerfile: 1.40kB                                                                                       0.0s
 => [internal] load metadata for gcr.io/distroless/static:nonroot                                                            0.8s
 => [internal] load metadata for docker.io/library/golang:1.21                                                               1.2s
 => [internal] load .dockerignore                                                                                            0.0s
 => => transferring context: 160B                                                                                            0.0s
 => [builder 1/9] FROM docker.io/library/golang:1.21@sha256:4746d26432a9117a5f58e95cb9f954ddf0de128e9d5816886514199316e4a2f  0.0s
 => [internal] load build context                                                                                            0.0s
 => => transferring context: 915B                                                                                            0.0s
 => CACHED [stage-1 1/3] FROM gcr.io/distroless/static:nonroot@sha256:8dd8d3ca2cf283383304fd45a5c9c74d5f2cd9da8d3b077d720e2  0.0s
 => CACHED [builder 2/9] WORKDIR /workspace                                                                                  0.0s
 => CACHED [builder 3/9] COPY go.mod go.mod                                                                                  0.0s
 => CACHED [builder 4/9] COPY go.sum go.sum                                                                                  0.0s
 => ERROR [builder 5/9] RUN go mod download                                                                                 30.4s
------                                                                                                                            
 > [builder 5/9] RUN go mod download:                                                                                             
30.32 go: github.com/beorn7/perks@v1.0.1: Get "https://proxy.golang.org/github.com/beorn7/perks/@v/v1.0.1.mod": dial tcp 216.58.199.241:443: i/o timeout
------
Dockerfile.manager:15
--------------------
  13 |     # cache deps before building and copying source so that we don't need to re-download as much
  14 |     # and so that source changes don't invalidate our downloaded layer
  15 | >>> RUN go mod download
  16 |     
  17 |     # Copy the go source
--------------------
ERROR: failed to solve: process "/bin/sh -c go mod download" did not complete successfully: exit code: 1
make: *** [Makefile:122: manager-image] Error 1
weichengintel commented 2 months ago

Workaround

As a temporary workaround, add --build-arg https_proxy=$(https_proxy) --build-arg http_proxy=$(http_proxy) to lines 122 and 127 in the Makefile:

# Build manager Docker image
manager-image:
    @echo "Building manager Docker image..."
    $(CONTAINER_TOOL) build -t $(DOCKER_REGISTRY)/${CTR_IMG}:$(VERSION) --build-arg https_proxy=$(https_proxy) --build-arg http_proxy=$(http_proxy) -f Dockerfile.manager .

# Build router Docker image
router-image:
    @echo "Building router Docker image..."
    $(CONTAINER_TOOL) build -t $(DOCKER_REGISTRY)/${ROUTER_IMG}:$(VERSION) --build-arg https_proxy=$(https_proxy) --build-arg http_proxy=$(http_proxy) -f Dockerfile.router .
xiguiw commented 1 week ago

Network issue. Could we close this?