Saturday, December 14, 2024
HomeGolangWhen deploy to server difficulty with "no required module gives bundle" -...

When deploy to server difficulty with “no required module gives bundle” – Getting Assist


I received difficulty when i construct docker in my server however i don’t know why i haven’t localy, right here is the stack hint:
“[6/6] RUN go construct -o /major:
0.505 handlers/handlers.go:5:2: no required module gives bundle githubcom/rousseau-romain/round-timing/shared/elements; so as to add it:
0.505 go get githubcom/rousseau-romain/round-timing/shared/elements
0.505 handlers/auth.go:9:2: no required module gives bundle githubcom/rousseau-romain/round-timing/views/web page; so as to add it:
0.505 go get githubcom/rousseau-romain/round-timing/views/web page

Dockerfile:11
9 | COPY . .
10 |
11 | >>> RUN go construct -o /major
12 |
13 | EXPOSE 2468

ERROR: failed to resolve: course of “/bin/sh -c go construct -o /major” didn’t full efficiently: exit code: 1″

My repository is public i don’t assume it’s proper difficulty, however perhaps i’m flawed.

https://github.com/rousseau-romain/round-timing

I needed to change “github.com/” to “githubcom/” with the hyperlink limitation.

Hope any person know tips on how to assist me

The go mod file appears to be like good and up to date.
I attempted so as to add go mod vendor in my dockerfile earlier than my go mod obtain however i received difficulty to search out exterior library.
“[7/7] RUN go construct -o /major
#11 0.378 major.go:11:2: can’t discover module offering bundle github.com/gorilla/mux: import lookup disabled by -mod=vendor
#11 0.378 (Go model in go.mod is not less than 1.14 and vendor listing exists.)
#11 0.378 config/config.go:8:2: can’t discover module offering bundle github.com/joho/godotenv: import lookup disabled by -mod=vendor”

With the intention to copy the exterior library offline into the container i have to have my vendor listing inside my container, localy when i construct my container localy i received my listing with exterior library.

The bundle github.com/rousseau-romain/ is a part of my native mission, it’s additionally thought-about as exterior library ?

Please present the mission listing construction, together with the dockerfile if attainable.

There may be the github hyperlink https://github.com/rousseau-romain/round-timing

The construction is like this:

├── config
├── database
│   └── migration
├── handlers
├── helper
├── mannequin
├── public
│   ├── img
│   │   ├── class
│   │   └── spell
│   │       └── pictures
│   └── script
├── service
│   └── auth
├── shared
│   └── elements
├── tmp
├── vendor
│   ├── github.com
│   │   ├── a-h
│   │   │   └── templ
│   │   │       └── safehtml
│   │   ├── go-sql-driver
│   │   │   └── mysql
│   │   ├── golang
│   │   │   └── protobuf
│   │   │       └── proto
│   │   ├── gorilla
│   │   │   ├── mux
│   │   │   ├── securecookie
│   │   │   └── classes
│   │   ├── huandu
│   │   │   ├── go-sqlbuilder
│   │   │   └── xstrings
│   │   ├── joho
│   │   │   └── godotenv
│   │   └── markbates
│   │       └── goth
│   │           ├── gothic
│   │           └── suppliers
│   │               ├── discord
│   │               └── github
│   ├── golang.org
│   │   └── x
│   │       └── oauth2
│   │           └── inner
│   └── google.golang.org
│       ├── appengine
│       │   ├── inner
│       │   │   ├── base
│       │   │   ├── datastore
│       │   │   ├── log
│       │   │   ├── remote_api
│       │   │   └── urlfetch
│       │   └── urlfetch
│       └── protobuf
│           ├── encoding
│           │   ├── prototext
│           │   └── protowire
│           ├── inner
│           │   ├── descfmt
│           │   ├── descopts
│           │   ├── detrand
│           │   ├── encoding
│           │   │   ├── defval
│           │   │   ├── messageset
│           │   │   ├── tag
│           │   │   └── textual content
│           │   ├── errors
│           │   ├── filedesc
│           │   ├── filetype
│           │   ├── flags
│           │   ├── genid
│           │   ├── impl
│           │   ├── order
│           │   ├── pragma
│           │   ├── set
│           │   ├── strs
│           │   └── model
│           ├── proto
│           ├── replicate
│           │   ├── protodesc
│           │   ├── protoreflect
│           │   └── protoregistry
│           ├── runtime
│           │   ├── protoiface
│           │   └── protoimpl
│           └── sorts
│               └── descriptorpb
└── views
    └── web page

The dockerfile is:

FROM golang:1.22-alpine

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod obtain

COPY . .

RUN go construct -o /major

EXPOSE 2468

CMD ["/main"]

The place is your major bundle? It is best to strive (I’m assuming you go.mod in . dir):

rm -rf ./vendor
go mod tidy
go mod vendor
go construct -o major . //if . is major bundle and might strive construct ...
FROM golang:1.22-alpine

WORKDIR /app

COPY . .

RUN go mod tidy // strive once more

RUN go construct -o /major . //if . is major bundle -> /app

EXPOSE 2468

CMD ["/main"]

Sure my major bundle is ., i attempted however git was not put in in alpine picture so i used golang:1.22 as an alternative and no git difficulty.

However now i received error with go mod tidy solely in server.
I have to create model tag in my github repo so as to construct in server ?

> [4/5] RUN go mod tidy:
1.292 go: downloading github.com/google/go-cmp v0.6.0
1.344 go: downloading google.golang.org/appengine v1.6.8
1.444 go: downloading github.com/golang/protobuf v1.5.3
1.750 go: downloading google.golang.org/protobuf v1.32.0
2.088 go: discovering module for bundle github.com/rousseau-romain/round-timing/views/web page
2.089 go: discovering module for bundle github.com/rousseau-romain/round-timing/shared/elements
5.754 go: github.com/rousseau-romain/round-timing/handlers imports
5.754 	github.com/rousseau-romain/round-timing/shared/elements: no matching variations for question "newest"
5.754 go: github.com/rousseau-romain/round-timing/handlers imports
5.754 	github.com/rousseau-romain/round-timing/views/web page: no matching variations for question "newest"

You might have an issue along with your code, you’ve an issue with import.
Have you ever actually tried a neighborhood construct? Such code is aware of at a look that it can’t be compiled.

When i compile my code localy i received no difficulty, bizarre.
Perhaps my configuration/set up will not be good domestically, i’ll attempt to take away go set up and reinstall.

➜  round-timing git:(grasp) ✗ docker construct -t round-timing . 
[+] Constructing 9.4s (10/10) FINISHED                                                                                                                                                                          
 => [internal] load construct definition from Dockerfile                                                                                                                                                   0.0s
 => => transferring dockerfile: 73B                                                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/golang:1.22                                                                                                                                         0.0s
 => [internal] load construct context                                                                                                                                                                      0.1s
 => => transferring context: 103.52kB                                                                                                                                                                  0.1s
 => [1/5] FROM docker.io/library/golang:1.22                                                                                                                                                           0.0s
 => CACHED [2/5] WORKDIR /app                                                                                                                                                                          0.0s
 => [3/5] COPY . .                                                                                                                                                                                     0.4s
 => [4/5] RUN go mod tidy                                                                                                                                                                              1.2s
 => [5/5] RUN go construct -o /major .                                                                                                                                                                      7.3s 
 => exporting to picture                                                                                                                                                                                 0.4s 
 => => exporting layers                                                                                                                                                                                0.4s 
 => => writing picture sha256:b5de9bc0452740ecd2c9800f2fc1371dda31c1388339c66936bc90c63b64417d                                                                                                           0.0s 
 => => naming to docker.io/library/round-timing   

The import for my native will not be the suitable approach to do it ?

github.com/rousseau-romain/round-timing/views/web page
It’s not a sound go bundle path as a result of there isn’t a go file in it, and I don’t know the way you run it, however there’s one thing flawed with the code itself.

Okay thanks i have a look !

When you’ve got the conduct of producing code, then you must commit the generated code to Git as an alternative of leaving a prototype.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments