awesome-fc / golang-runtime

Implement golang runtime based on custom runtime
27 stars 9 forks source link

有什么好办法解决docker go get github timeout? #5

Open xmsz opened 3 years ago

xmsz commented 3 years ago
FROM golang:1.16.3-stretch

RUN mkdir -p $GOPATH/src/golang.org/x/
RUN cd $GOPATH/src/golang.org/x/ && git clone https://github.com.cnpmjs.org/golang/net.git
RUN cd $GOPATH/src/golang.org/x/ &&  git clone https://github.com.cnpmjs.org/golang/sys.git
RUN go get github.com/awesome-fc/golang-runtime

直接部署,都会卡在最后一步,因为国内根本下不下来

如果设置了proxy

则出现

docker run --rm -it -v $(pwd):/tmp fc-go-runtime bash -c "go build -o /tmp/code//bootstrap /tmp/code/main.go"
/tmp/code/main.go:5:2: cannot find package "github.com/awesome-fc/golang-runtime" in any of:
    /usr/local/go/src/github.com/awesome-fc/golang-runtime (from $GOROOT)
    /go/src/github.com/awesome-fc/golang-runtime (from $GOPATH)
make: *** [build] Error 1
yin1999 commented 3 years ago

Enable Go Modules, and then using go get to get all packages.

go.mod

module xxx

go 1.17

require (
    golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e
    golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
)

Dockerfile

RUN export GOPROXY=https://goproxy.cn,direct && go mod tidy && go mod download