netlify / gotrue

An SWT based API for managing users and issuing SWT tokens.
https://www.gotrueapi.org
MIT License
3.78k stars 279 forks source link

Fix docker image build #336

Closed rbarabas closed 1 year ago

rbarabas commented 1 year ago

Fixes docker image build issue

The image fails to build due to a go oauth2 package dependency issue outlined in https://github.com/aws-observability/aws-otel-collector/issues/926.

During build you would encounter the following error:

2023-02-14T20:29:04Z #16 [build 6/7] COPY . /go/src/github.com/netlify/gotrue
2023-02-14T20:29:04Z #16 DONE 0.1s
2023-02-14T20:29:04Z
2023-02-14T20:29:04Z #17 [build 7/7] RUN make build
2023-02-14T20:29:04Z #17 0.419 go build -ldflags "-X github.com/netlify/gotrue/cmd.Version=`git rev-parse HEAD`"
2023-02-14T20:29:06Z #17 1.776 /go/pkg/mod/golang.org/x/oauth2@v0.0.0-20220524215830-622c5d57e401/google/default.go:17:2: ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules:
2023-02-14T20:29:06Z #17 1.776 cloud.google.com/go/compute v1.6.1 (/go/pkg/mod/cloud.google.com/go/compute@v1.6.1/metadata)
2023-02-14T20:29:06Z #17 1.776 cloud.google.com/go/compute/metadata v0.2.0 (/go/pkg/mod/cloud.google.com/go/compute/metadata@v0.2.0)
2023-02-14T20:29:06Z #17 1.778 make: *** [Makefile:13: build] Error 1
2023-02-14T20:29:06Z #17 ERROR: executor failed running [/bin/sh -c make build]: exit code: 2
2023-02-14T20:29:06Z
2023-02-14T20:29:06Z #10 [build 1/7] FROM docker.io/library/golang:1.15-alpine@sha256:b58c367d52e46cdedc25ec9cd74cadb14ad65e8db75b25e5ec117cdb227aa264
2023-02-14T20:29:06Z ------
2023-02-14T20:29:06Z > [build 7/7] RUN make build:
2023-02-14T20:29:06Z #17 0.419 go build -ldflags "-X github.com/netlify/gotrue/cmd.Version=`git rev-parse HEAD`"
2023-02-14T20:29:06Z #17 1.776 /go/pkg/mod/golang.org/x/oauth2@v0.0.0-20220524215830-622c5d57e401/google/default.go:17:2: ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules:
2023-02-14T20:29:06Z #17 1.776 cloud.google.com/go/compute v1.6.1 (/go/pkg/mod/cloud.google.com/go/compute@v1.6.1/metadata)
2023-02-14T20:29:06Z #17 1.776 cloud.google.com/go/compute/metadata v0.2.0 (/go/pkg/mod/cloud.google.com/go/compute/metadata@v0.2.0)
2023-02-14T20:29:06Z #17 1.778 make: *** [Makefile:13: build] Error 1
2023-02-14T20:29:06Z ------
2023-02-14T20:29:06Z ERROR: failed to solve: executor failed running [/bin/sh -c make build]: exit code: 2
2023-02-14T20:29:06Z Build failed using Buildkit (1)

In order to solve this I had to execute the following command to update the problematic dependency:

$ go get cloud.google.com/go/compute/metadata && go mod tidy

Updates the go module files to fix a dependency problem

rbarabas commented 1 year ago

Apologies, submitted to the wrong repository!