我正在尝试构建一个 Docker 容器,该容器下载https://github.com/micromdm/scep的源代码并使用go get
命令和cd
s 进入结果目录以执行一些后续命令(即make deps
,make build
和COPY
将相关生成的二进制文件放入容器的PATH
) 中。
到目前为止,我已经尝试过Dockerfile
:
FROM golang:latest
ENV GO111MODULE on
RUN ["go", "get", "github.com/micromdm/scep"]
RUN cd $GOPATH/src/github.com/micromdm/scep
但是,如果我尝试运行它,我会收到以下错误:
> docker build . --tag loadtest
Sending build context to Docker daemon 4.608kB
Step 1/4 : FROM golang:latest
---> 52b59e9ead8e
Step 2/4 : ENV GO111MODULE on
---> Using cache
---> 28335bf0142b
Step 3/4 : RUN ["go", "get", "github.com/micromdm/scep"]
---> Using cache
---> 86760bf0c490
Step 4/4 : RUN cd $GOPATH/src/github.com/micromdm/scep
---> Running in b86fc3ab0ab8
/bin/sh: 1: cd: can't cd to /go/src/github.com/micromdm/scep
The command '/bin/sh -c cd $GOPATH/src/github.com/micromdm/scep' returned a non-zero code: 2
GO111MODULE
如果我在没有将环境变量设置为 的情况下尝试该命令on
,我会得到他的错误:
> docker build . --tag loadtest
Sending build context to Docker daemon 4.608kB
Step 1/3 : FROM golang:latest
---> 52b59e9ead8e
Step 2/3 : RUN ["go", "get", "github.com/micromdm/scep"]
---> Running in 8cb54311a416
package github.com/micromdm/scep: no Go files in /go/src/github.com/micromdm/scep
The command 'go get github.com/micromdm/scep' returned a non-zero code: 1
在https://github.com/ponzu-cms/ponzu/issues/204之后,我还尝试...
在最后运行它,
FROM golang:latest
RUN ["go", "get", "github.com/micromdm/scep/..."]
RUN cd $GOPATH/src/github.com/micromdm/scep \
但这会导致
> docker build . --tag loadtest
Sending build context to Docker daemon 4.608kB
Step 1/3 : FROM golang:latest
---> 52b59e9ead8e
Step 2/3 : RUN ["go", "get", "github.com/micromdm/scep/..."]
---> Running in 961bae3bb455
# github.com/micromdm/scep/scep
src/github.com/micromdm/scep/scep/scep.go:318:17: p7.EncryptionAlgorithm undefined (type *pkcs7.PKCS7 has no field or method EncryptionAlgorithm)
src/github.com/micromdm/scep/scep/scep.go:449:26: too many arguments in call to pkcs7.Encrypt
src/github.com/micromdm/scep/scep/scep.go:449:53: undefined: pkcs7.WithEncryptionAlgorithm
src/github.com/micromdm/scep/scep/scep.go:542:26: too many arguments in call to pkcs7.Encrypt
src/github.com/micromdm/scep/scep/scep.go:542:54: undefined: pkcs7.WithEncryptionAlgorithm
The command 'go get github.com/micromdm/scep/...' returned a non-zero code: 2
关于如何实现下载包并cd
进入结果目录的任何想法?