【发布时间】:2020-04-27 20:36:41
【问题描述】:
这个问题只是在构建之间随机出现,现在甚至我们的生产 repo(几个月没有改变)在构建时也会出现这个问题。我已经坚持了一段时间。它不会发生在我们的本地机器上,只有在使用 dockerfile 时才会发生。
Step 30/73 : RUN go get -d ./...
---> Running in ca969a5fc165
[91msrc/golang.org/x/text/cmd/gotext/main.go:31:2: cannot find package "golang.org/x/tools/go/buildutil" in any of:
/usr/local/go/src/golang.org/x/tools/go/buildutil (from $GOROOT)
/app/src/golang.org/x/tools/go/buildutil (from $GOPATH)
src/golang.org/x/text/message/pipeline/extract.go:23:2: cannot find package "golang.org/x/tools/go/callgraph" in any of:
/usr/local/go/src/golang.org/x/tools/go/callgraph (from $GOROOT)
/app/src/golang.org/x/tools/go/callgraph (from $GOPATH)
src/golang.org/x/text/message/pipeline/extract.go:24:2: cannot find package "golang.org/x/tools/go/callgraph/cha" in any of:
/usr/local/go/src/golang.org/x/tools/go/callgraph/cha (from $GOROOT)
/app/src/golang.org/x/tools/go/callgraph/cha (from $GOPATH)
src/golang.org/x/text/message/pipeline/extract.go:25:2: cannot find package "golang.org/x/tools/go/loader" in any of:
/usr/local/go/src/golang.org/x/tools/go/loader (from $GOROOT)
/app/src/golang.org/x/tools/go/loader (from $GOPATH)
src/golang.org/x/text/message/pipeline/extract.go:26:2: cannot find package "golang.org/x/tools/go/ssa" in any of:
/usr/local/go/src/golang.org/x/tools/go/ssa (from $GOROOT)
/app/src/golang.org/x/tools/go/ssa (from $GOPATH)
src/golang.org/x/text/message/pipeline/extract.go:27:2: cannot find package "golang.org/x/tools/go/ssa/ssautil" in any of:
/usr/local/go/src/golang.org/x/tools/go/ssa/ssautil (from $GOROOT)
/app/src/golang.org/x/tools/go/ssa/ssautil (from $GOPATH)
[0mThe command '/bin/sh -c go get -d ./...' returned a non-zero code: 1
我已经将所有这些依赖项(减去第一个)跟踪到 golang.org/x/text/message/pipeline/extract.go 中的一个文件。它们都被列为进口商品。下面是我们dockerfile的相关部分
RUN yum update -y
RUN yum install -y git-core
RUN yum install -y wget
RUN yum install -y gcc-c++ make
RUN yum install -y libaio
RUN yum install -y openssl-devel
# Install Go
RUN wget --no-check-certificate https://dl.google.com/go/go1.12.2.linux-amd64.tar.gz
RUN tar -xzf go1.12.2.linux-amd64.tar.gz
RUN mv go /usr/local
RUN rm go1.12.2.linux-amd64.tar.gz
# Copy application files
COPY ./ /app
WORKDIR /app
# Configure paths for GOPATH and GOROOT
ENV GOROOT="/usr/local/go"
ENV GOPATH="/app"
ENV GOBIN="$GOPATH/bin"
ENV PATH="$PATH:$GOPATH/bin:$GOROOT/bin"
# Install Go dependencies
RUN go get github.com/creack/pty
RUN go get -d -v ./...
RUN go install -v ./...
【问题讨论】:
标签: go dockerfile