Golang:作为makefile的一部分调用时,go生成失败

Golang:作为makefile的一部分调用时,go生成失败,go,docker,Go,Docker,我有以下文件: default: builddocker setup: go get github.com/golang/protobuf/proto go get github.com/golang/protobuf/protoc-gen-go go get golang.org/x/net/context go get google.golang.org/grpc buildgo: CGO_ENABLED=0 GOOS=linux go b

我有以下文件:

default: builddocker

setup:
     go get github.com/golang/protobuf/proto
     go get github.com/golang/protobuf/protoc-gen-go
     go get golang.org/x/net/context
     go get google.golang.org/grpc

buildgo:
    CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo -o main ./customer-server/

builddocker:
                    docker build -t johnwesonga/grpc/customer-server -f ./Dockerfile.build .
                    docker run -t johnwesonga/grpc/customer-server /bin/true
                    docker cp `docker ps -q -n=1`:/main .
                    chmod 755 ./main
                    docker build --rm=true --tag=johnwesonga/grpc/customer-server -f Dockerfile.static .
My Dockerfile.build具有:

FROM golang

ADD Makefile /
WORKDIR /
RUN make setup

RUN make buildgo
CMD ["/bin/bash"]
但每次运行“make builddocker”时,都会出现以下错误:

CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo -o main ./customer-server/
can't load package: package ./customer-server: open /customer-server: no such file or directory
make: *** [buildgo] Error 1
Makefile:10: recipe for target 'buildgo' failed
The command '/bin/sh -c make buildgo' returned a non-zero code: 2
make: *** [builddocker] Error 2
但如果我运行“makebuildgo”,它运行得很好,你知道为什么会失败吗

仅供参考,我的源代码树如下:

/go/src/github.com/johnwesonga/grpc/MakeFile
/go/src/github.com/johnwesonga/grpc/customer-server
/go/src/github.com/johnwesonga/grpc/customer-server/main.go

看起来您正在将Makefile而不是
客户服务器
目录添加到映像中。这是否来自其他地方?客户服务器是一个包含我的go代码的目录。我理解,我要说的是,它看起来不像是将其复制到容器中或将其作为卷装载。您的代码永远不会与Makefile位于同一位置。这就是错误消息所说的,容器内没有可编译的内容。请在buildgo步骤中添加
find/-print
,以查看容器中的可用内容。R0MANARMY是正确的。看起来您正在将Makefile而不是
客户服务器
目录添加到映像中。这是否来自其他地方?客户服务器是一个包含我的go代码的目录。我理解,我要说的是,它看起来不像是将其复制到容器中或将其作为卷装载。您的代码永远不会与Makefile位于同一位置。这就是错误消息所说的,容器内没有可编译的内容。请在buildgo步骤中添加
find/-print
,以查看容器中的可用内容。r0管理是正确的。