Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot download library in docker build #425

Open
ljahier opened this issue Aug 28, 2023 · 2 comments
Open

Cannot download library in docker build #425

ljahier opened this issue Aug 28, 2023 · 2 comments

Comments

@ljahier
Copy link

ljahier commented Aug 28, 2023

Hello,

Issue Description:
When running a docker build -t my-app-name . command, the go mod download step is triggered to install project dependencies. However, an error is encountered during this process that prevents successful dependency installation. The specific error message is as follows:

=> ERROR [4/7] RUN go mod download                                                                                                                                                                                                                                                                                                                                    2.7s
------
 > [4/7] RUN go mod download:
2.588 go: github.com/gabriel-vasile/mimetype@v1.4.2: reading https://proxy.golang.org/github.com/gabriel-vasile/mimetype/@v/v1.4.2.zip: 403 Forbidden
------
Dockerfile:9
--------------------
   7 |     # Download Go modules
   8 |     COPY go.mod go.sum ./
   9 | >>> RUN go mod download
  10 |
  11 |
--------------------
ERROR: failed to solve: process "/bin/sh -c go mod download" did not complete successfully: exit code: 1```

Expected Behavior:
The go mod download step should successfully install the project dependencies without encountering any errors related to the github.com/gabriel-vasile/mimetype dependency.

Actual Behavior:
The go mod download step encounters a 403 Forbidden error when trying to access the following URL:
https://proxy.golang.org/github.com/gabriel-vasile/mimetype/@v/v1.4.2.zip

Additional Context:

  • When attempting to access the URL https://proxy.golang.org/github.com/gabriel-vasile/mimetype/@v/v1.4.2.zip directly from the browser on my laptop, I can confirm that I can access the URL without any issues. The zip file downloads successfully.

  • Furthermore, when I use the wget command on my server (which is hosted at Hetzner and utilizes an ARM processor), I am also able to successfully download the zip file without encountering any access restrictions or errors.

  • It seems that the issue is isolated to the environment of running a docker build on my server. It's puzzling that I can access the URL from various contexts except during the Docker build process. This might suggest that there could be a specific configuration or network-related factor within the Docker build environment that's causing this 403 Forbidden error. But I don't know why, because all others dependencies download well

  • I have the same issue when I run go mod tidy instead of go mod download

Dockerfile:

FROM golang:1.21

WORKDIR /app

# Download Go modules
COPY go.mod go.sum ./
RUN go mod download

COPY . .

COPY xxxx-api.conf /app/.env

RUN CGO_ENABLED=0 GOOS=linux go build -o api

EXPOSE 8080

CMD ["./api"]

Environment Details:

@ljahier ljahier changed the title Issue with go mod tidy during Docker build due to github.com/gabriel-vasile/mimetype Issue with go mod download during Docker build due to github.com/gabriel-vasile/mimetype Aug 28, 2023
@ljahier ljahier changed the title Issue with go mod download during Docker build due to github.com/gabriel-vasile/mimetype Cannot download library in docker build Aug 28, 2023
@gabriel-vasile
Copy link
Owner

Hi, unfortunately I cannot reproduce the problem.

This issue seems to be related. Can you try any of the suggestions there?
Someone says the problem happens for big repositories, which might be the case here: mimetype has many test files.

@fbarikzehi
Copy link

I had the same problem.just set GOPROXY=direct:
GOPROXY=direct go get github.com/gabriel-vasile/mimetype

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

No branches or pull requests

3 participants