[英]How to build and push Go image using Google Ko?Could you tell me the steps for cloudbuild.yaml to create the image and push go image using Google ko?
I need to build go project using google Ko after checking out from git and then push the image to private artifactory which takes credentials.从 git 签出后,我需要使用 google Ko 构建 go 项目,然后将图像推送到需要凭据的私有工件。 How to define the steps for the above in cloudbuild.yaml?如何在 cloudbuild.yaml 中定义上述步骤? Steps where it takes Source path and also where it takes private repository path.采用源路径以及采用私有存储库路径的步骤。 How to give the credentials of artifactory through script?如何通过脚本赋予神器的凭据?
Error you are getting is due the failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "bash"
您收到的错误是由于failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "bash"
By default, the ko command uses a secure and lean base image from the Distroless collection of images (the gcr.io/distroless/static:nonroot image), which doesn't contain a shell or other executables in order to reduce the attack surface of the container.默认情况下,ko 命令使用来自 Distroless 镜像集合(gcr.io/distroless/static:nonroot 镜像)的安全且精简的基础镜像,该镜像不包含 shell 或其他可执行文件以减少攻击面的容器。
You can first create the Ko docker image and we will use this docker image as the base iamge to Cloudbuild.您可以先创建Ko docker 镜像,我们将使用这个 docker 镜像作为 Cloudbuild 的基础镜像。 We will push and save the Ko docker image to GCR我们将Ko docker 镜像推送并保存到GCR
Github: https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/ko Github: https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/ko
There is cloudbuild.yaml
to build image on cloudbuild or you also run docker build -t
locally to build docker有cloudbuild.yaml
上构建映像,或者您也可以在本地运行docker build -t
来构建 docker
Once docker image is built and pushed to the GCR we can write the cloudbuild.yaml
to build the application构建 docker 映像并将其推送到GCR后,我们可以编写cloudbuild.yaml
来构建应用程序
Try this Cloudbuild.yaml
for example试试这个Cloudbuild.yaml
例如
steps:
- name: gcr.io/$PROJECT_ID/ko
entrypoint: /bin/sh
env:
- 'KO_DOCKER_REPO=gcr.io/$PROJECT_ID'
args:
- -c
- |
echo $(/ko publish --preserve-import-paths ./cmd/ko) > ./ko_container.txt || exit 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.