【发布时间】:2018-06-14 21:02:03
【问题描述】:
我有一个路径为/Users/me/Documents/dev/grafana/src/github.com/grafana/grafana 的项目。该项目使用了其他几个项目,例如:
/Users/me/Documents/dev/grafana/src/github.com/BurntSushi/toml
/Users/me/Documents/dev/grafana/src/github.com/Unknwon/com
我可以在我的机器上构建一切都很好,但是当我尝试在 Docker 中构建时,我得到了一堆 cannot find package 错误。
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)
当我自己构建时,我有 $GOPATH=/Users/me/Documents/dev/grafana/ -- 在我的 Dockerfile 中我有:
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
我不明白为什么这个步骤(Wich 从RUN go run build.go setup 步骤开始)一直报告它无法访问包。
我已经四处寻找类似的问题,但几乎所有相关的内容都没有指定在 Docker 中构建(而且那些对这种情况没有太大帮助的问题)。
【问题讨论】:
-
我用的是这个:github.com/immortal/immortal/blob/master/Dockerfile,希望能给你一个思路
-
谢谢。它看起来几乎就像期望这些路径已经存在。他们没有,在发出build.go setup 时应该获取它们(我认为)
标签: docker go dockerfile grafana