I have a project with the path /Users/me/Documents/dev/grafana/src/github.com/grafana/grafana
. This project uses several other projects, for example:
/Users/me/Documents/dev/grafana/src/github.com/BurntSushi/toml
/Users/me/Documents/dev/grafana/src/github.com/Unknwon/com
I can build everything fine on my machine, but when I try to build within Docker, I get a bunch of cannot find package
errors.
go install -v ./pkg/cmd/grafana-server
pkg/login/ldap_settings.go:7:2: cannot find package "github.com/BurntSushi/toml" in any of:
/usr/local/go/src/github.com/BurntSushi/toml (from $GOROOT)
/go/src/github.com/BurntSushi/toml (from $GOPATH)
pkg/services/notifications/codes.go:9:2: cannot find package "github.com/Unknwon/com" in any of:
/usr/local/go/src/github.com/Unknwon/com (from $GOROOT)
/go/src/github.com/Unknwon/com (from $GOPATH)
When I build myself, I have $GOPATH=/Users/me/Documents/dev/grafana/
– in my Dockerfile I have:
FROM golang:latest AS build
RUN go version
ENV SRC_DIR=/go/src/github.com/grafana/grafana/
ENV GIT_SSL_NO_VERIFY=1
COPY . $SRC_DIR
WORKDIR $SRC_DIR
[... dependency installations ...]
# Building of Grafana
RUN npm run build
RUN go run build.go setup
RUN go run build.go build
I can’t figure out why this step (specifically, the RUN go run build.go setup
step) keeps reporting that it can’t access the packages.
I’ve looked around for similar questions, but almost everything related doesn’t specify building in Docker (and the ones that do aren’t super helpful for this scenario).