Closed lightSoulDev closed 1 year ago
I need to mention that ./generated/gqlmodel/generated.go
is generated correctly, and the Role type is presented therein.
from line 427
type Role string
const (
RoleAdmin Role = "ADMIN"
RoleUser Role = "USER"
)
var AllRole = []Role{
RoleAdmin,
RoleUser,
}
func (e Role) IsValid() bool {
switch e {
case RoleAdmin, RoleUser:
return true
}
return false
}
func (e Role) String() string {
return string(e)
}
func (e *Role) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = Role(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid Role", str)
}
return nil
}
func (e Role) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}
Cannot reproduce, the Dockerfile.dev builds fine for me. Your error messages seem fishy, generated.Roleo
and generated.Roleable
. Are you sure you haven't done any changes to the source code? Could you paste the full output of the docker-compose up?
Yep, 0 changes. It appears that my console is trimming the error. The full error from running in debug mode is:
merging failed: unable to find type github.com/traggo/server/generated/gqlmodel.Role
Here is the docker-compose up -d
output:
[+] Building 123.4s (10/11) docker:default
=> [traggo internal] load build definition from Dockerfile.dev 0.0s
=> => transferring dockerfile: 407B 0.0s
=> [traggo internal] load .dockerignore 0.0s
=> => transferring context: 119B 0.0s
=> [traggo internal] load metadata for docker.io/library/golang:1.18.1 2.3s
=> [traggo builder 1/5] FROM docker.io/library/golang:1.18.1@sha256:12d3995156cb0dcdbb9d3edb5827e4e8e1bf5bf92436bfd12d696ec997001a9a 0.0s
=> [traggo internal] load build context 0.0s
=> => transferring context: 149.58kB 0.0s
=> CACHED [traggo stage-1 1/2] WORKDIR /opt/traggo 0.0s
=> CACHED [traggo builder 2/5] RUN apt-get update && apt-get install --yes nodejs npm && npm install --global yarn 0.0s
=> CACHED [traggo builder 3/5] WORKDIR /app 0.0s
=> [traggo builder 4/5] COPY . . 0.1s
=> ERROR [traggo builder 5/5] RUN make download-tools install generate build-bin-local 121.0s
------
> [traggo builder 5/5] RUN make download-tools install generate build-bin-local:
0.284 go install golang.org/x/tools/cmd/goimports@v0.1.10
0.759 go: downloading golang.org/x/tools v0.1.10
2.495 go: downloading golang.org/x/sys v0.0.0-20211019181941-9d821ace8654
2.498 go: downloading golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3
2.919 go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
4.424 go install github.com/gobuffalo/packr/v2/packr2@v2.7.1
4.733 go: downloading github.com/gobuffalo/packr/v2 v2.7.1
9.604 go: downloading github.com/gobuffalo/envy v1.7.1
9.604 go: downloading github.com/spf13/cobra v0.0.5
9.604 go: downloading github.com/gobuffalo/logger v1.0.1
9.604 go: downloading golang.org/x/tools v0.0.0-20191004055002-72853e10c5a3
9.604 go: downloading github.com/gobuffalo/packd v0.3.0
9.606 go: downloading github.com/sirupsen/logrus v1.4.2
9.607 go: downloading golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
9.609 go: downloading github.com/rogpeppe/go-internal v1.4.0
9.785 go: downloading github.com/spf13/pflag v1.0.3
9.818 go: downloading golang.org/x/sys v0.0.0-20190515120540-06a5c4944438
9.835 go: downloading github.com/joho/godotenv v1.3.0
9.839 go: downloading golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
12.71 go mod download
22.01 (cd ui && yarn)
22.27 yarn install v1.22.19
22.35 [1/4] Resolving packages...
22.84 [2/4] Fetching packages...
78.74 [3/4] Linking dependencies...
78.75 warning " > @apollo/react-hooks@3.1.3" has unmet peer dependency "apollo-client@^2.6.4".
78.75 warning "@apollo/react-hooks > @apollo/react-common@3.1.3" has unmet peer dependency "apollo-client@^2.6.4".
78.75 warning "@apollo/react-hooks > @apollo/react-common@3.1.3" has unmet peer dependency "apollo-utilities@^1.3.2".
78.75 warning " > @material-ui/pickers@3.2.8" has unmet peer dependency "@date-io/core@^1.3.6".
78.75 warning " > @material-ui/pickers@3.2.8" has unmet peer dependency "prop-types@^15.6.0".
78.75 warning " > notistack@0.6.1" has incorrect peer dependency "@material-ui/core@^3.2.0".
78.75 warning " > react-apollo@3.1.3" has unmet peer dependency "apollo-client@^2.6.4".
78.75 warning "react-apollo > @apollo/react-components@3.1.3" has unmet peer dependency "apollo-cache@^1.3.2".
78.75 warning "react-apollo > @apollo/react-components@3.1.3" has unmet peer dependency "apollo-client@^2.6.4".
78.75 warning "react-apollo > @apollo/react-components@3.1.3" has unmet peer dependency "apollo-link@^1.2.12".
78.75 warning "react-apollo > @apollo/react-components@3.1.3" has unmet peer dependency "apollo-utilities@^1.3.2".
78.75 warning "react-apollo > @apollo/react-hoc@3.1.3" has unmet peer dependency "apollo-client@^2.6.4".
78.75 warning " > react-infinite@0.13.0" has unmet peer dependency "prop-types@^15.5.0".
78.75 warning "react-infinite > enzyme-adapter-react-16@1.1.1" has unmet peer dependency "enzyme@^3.0.0".
116.1 [4/4] Building fresh packages...
117.6 Done in 95.36s.
117.7 go run hack/gqlgen/gqlgen.go
.Role merging failed: unable to find type github.com/traggo/server
120.7
120.7 exit status 3
120.7 make: *** [Makefile:30: generate-go] Error 1
------
failed to solve: process "/bin/sh -c make download-tools install generate build-bin-local" did not complete successfully: exit code: 2
Hmm, don't know. The error is happening inside gqlgen. This dependency is pretty outdated in this project, so this error may be fixed when gqlgen is updated, but don't know what changes they made that potentially break traggo/server.
Docker should ensure, that we have the exact same environment, so I'm not sure I can assist debugging there as I can't reproduce it.
$ docker-compose build
=> [traggo internal] load build definition from Dockerfile.dev 0.0s
=> => transferring dockerfile: 392B 0.0s
=> [traggo internal] load .dockerignore 0.0s
=> => transferring context: 114B 0.0s
=> [traggo internal] load metadata for docker.io/library/golang:1.18.1 1.1s
=> [traggo auth] library/golang:pull token for registry-1.docker.io 0.0s
=> [traggo builder 1/5] FROM docker.io/library/golang:1.18.1@sha256:12d3995156cb0dcdbb9d3edb5827e4e8e1bf5bf92436bfd12d696ec997001a9a 0.0s
=> [traggo internal] load build context 0.0s
=> => transferring context: 452.34kB 0.0s
=> CACHED [traggo stage-1 1/2] WORKDIR /opt/traggo 0.0s
=> CACHED [traggo builder 2/5] RUN apt-get update && apt-get install --yes nodejs npm && npm install --global yarn 0.0s
=> CACHED [traggo builder 3/5] WORKDIR /app 0.0s
=> [traggo builder 4/5] COPY . . 0.1s
=> [traggo builder 5/5] RUN make download-tools install generate build-bin-local 142.7s
=> [traggo stage-1 2/2] COPY --from=builder /app/build/traggo-server /opt/traggo/traggo 0.3s
=> [traggo] exporting to image 0.4s
=> => exporting layers 0.4s
=> => writing image sha256:96ef146045dac627ae6561d93f94452497fe93f41af27d67b090207b84881c3f 0.0s
=> => naming to docker.io/library/x-traggo 0.0s
Yes, I understand. I will attempt to update gqlgen to see if this issue persists across all reasonable versions.
My docker engine version is Docker version 24.0.6, build ed223bc
The issue was in my docker engine.
I was using Docker version 24.0.6, build ed223bc on my windows server
.
Building the compose on all other non-Windows machines proceeded without any issues. I apologize for not specifying this earlier, as I assumed that Docker would exhibit consistent behavior across all platforms.
P.S. I resolved this problem on my Windows server by using WSL2 and running everything through it.
Describe the bug When constructing a Docker container from source, the command RUN make download-tools install generate build-bin-local fails with:
The problem lies in
go run hack/gqlgen/gqlgen.go
. After installing github.com/99designs/gqlgen v0.9.0 along with all its dependencies and executinggo run hack/gqlgen/gqlgen.go
in debug mode, the error output is much cleaner:To Reproduce Steps to reproduce the behavior:
docker-compose up
Expected behavior I expected the Docker image to build correctly.
Additional context
Outputs