Golang:当作为makefile的一部分调用时,构建失败

时间:2016-11-02 04:22:55

标签: go docker

我有以下make文件:

./hibImport.sh /home/nandhinilk/Desktop/sample sample.hib

我的Dockerfile.build有:

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 .

但每次我运行“make builddocker”时都会出现以下错误:

FROM golang

ADD Makefile /
WORKDIR /
RUN make setup

RUN make buildgo
CMD ["/bin/bash"]

但是如果我运行“Make buildgo”它运行得很好,任何想法为什么会失败?

我的源代码树如下:

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

0 个答案:

没有答案