我正在使用云构建来构建一个 docker 图像从github上提供的示例中引导自己:- - - 垃圾桶------包装------源码 --cloud.google.com
--contrib.go.opencensus.io
--github.com
--go.opencensus.io
--golang.org
--google.golang.org
--me
--backend------cloudbuild.yaml------Docker文件我所有的代码都在 src -> me -> backend 中云构建步骤.yaml文件内容为: steps:
- name: 'gcr.io/cloud-builders/go'
args: ['install', 'me/backend']
env: ['GOPATH=.']
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=gcr.io/superpack-213022/me/backend', '.']
images: ['gcr.io/superpack-213022/me/backend']码头文件:FROM scratch
COPY bin/backend /me/backend
ENTRYPOINT ["/me/backend"]给我这个错误:can not find a package golang/x/sys/unix in any of ...
1 回答
九州编程
TA贡献1785条经验 获得超4个赞
对于有同样问题的用户,最大的问题是 go dependecies args: ['install', 'me/backend'] “install” 是阻止我完成构建的瓶颈,出于某种原因,“install” 不获取所有的依赖项,你需要先用这个获取所有的依赖项:args: ['get','-d','me/backend/...'], 很明显你改变了你想要的存储库的“me/backend”建造。
我的本地存储库设置如何:
- - -垃圾桶
------包装
------源码
--cloud.google.com #dependency --contrib.go.opencensus.io #dependency --github.com #dependency --go.opencensus.io #dependency --golang.org #dependency --google.golang.org #dependency --me #my code --backend . . --deploy cloudbuild.yaml Dockerfile
此外,我将“src/me”中的所有代码移至谷歌云存储库
cloudbuild.yaml: steps: - name: 'gcr.io/cloud-builders/gcloud-slim' args: ['source','repos','clone', '[repositorie name]','src/me','--project=[project name]'] #change [repositorie name] and [project name] for your repositorie name and project name respectively - name: 'gcr.io/cloud-builders/go' args: ['get','-d','me/backend/...'] - name: 'gcr.io/cloud-builders/go' args: ['install', 'me/backend'] env: ['GOPATH=.'] - name: 'gcr.io/cloud-builders/docker' args: ['build', '--tag=gcr.io/[project name]/me/backend', '.'] #change [project name] with your project name images: ['gcr.io/[project name]/me/backend'] #change [project name] with your project name artifacts: objects: location: 'gs://[your bucket name]/backend/' #change [your bucket name] for your bucket name paths: ['./bin/backend']
文件:
FROM alpine COPY bin/backend /backend RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* CMD ["/backend"] RUN chmod 755 /backend
在命令行中你应该(以我的本地存储库为例):
cd src/me/deploy gcloud builds submit .
- 1 回答
- 0 关注
- 134 浏览
添加回答
举报
0/150
提交
取消