我的Dockerfile
FROM golang:1.10.2-alpine3.7 AS build
RUN apk --no-cache add gcc g++ make ca-certificates
RUN apk add git
WORKDIR /go/src/github.com/meower
COPY Gopkg.lock Gopkg.toml ./
COPY util util
COPY event event
COPY db db
COPY search search
COPY schema schema
COPY meow-service meow-service
COPY query-service query-service
COPY pusher-service pusher-service
RUN go get -d -v ./...
RUN go install ./...
FROM alpine:3.7
WORKDIR /usr/bin
COPY --from=build /go/bin .
我添加了apk添加git行。没有这一行,我的docker-compose up产生了
Step 13/17 : RUN go get -d -v ./...
---> Running in d917adba00cd
github.com/lib/pq (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/lib/pq: exec: "git": executable file not found in $PATH
github.com/nats-io/go-nats (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/nats-io/go-nats: exec: "git": executable file not found in $PATH
github.com/gorilla/mux (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gorilla/mux: exec: "git": executable file not found in $PATH
github.com/kelseyhightower/envconfig (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/kelseyhightower/envconfig: exec: "git": executable file not found in $PATH
package github.com/retry: invalid github.com/ import path "github.com/retry"
github.com/segmentio/ksuid (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/segmentio/ksuid: exec: "git": executable file not found in $PATH
github.com/gorilla/websocket (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gorilla/websocket: exec: "git": executable file not found in $PATH
github.com/olivere/elastic (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/olivere/elastic: exec: "git": executable file not found in $PATH
使用git行,其他问题仍然存在
docker-compose up
Building pusher
Step 1/18 : FROM golang:1.10.2-alpine3.7 AS build
---> 44ccce322b34
Step 2/18 : RUN apk --no-cache add gcc g++ make ca-certificates
---> Using cache
---> 088fa5ba19a9
Step 3/18 : RUN apk add git
---> Running in 01022f57861b
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
git (missing):
这是什么意思?
答案 0 :(得分:1)
go get
在内部调用特定VCS的“参考”客户端工具,该工具用于托管要获取的程序包。换句话说,go get
本身不知道如何与VCS服务器进行交互。
是的,为了go get
由Git托管的软件包,您需要工作的Git安装程序提供可调用的git
二进制文件。
关于第二个问题,does not appear to have anything related to Go,所以我建议您做一点研究,然后再问一个标记为alpine
的单独问题,如果失败了。