简体   繁体   English

如何使用 Google Ko 构建和推送 Go 映像?你能告诉我 cloudbuild.yaml 创建映像并使用 Google 推送 go 映像的步骤吗?

[英]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 dockercloudbuild.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.

相关问题 Cloud Build 不会将我的 Docker 图像推送到带有 cloudbuild.yaml 图像字段的 Artifact Registry - Cloud Build does not push my Docker image to Artifact Registry with images field in cloudbuild.yaml 从工件注册表中删除图像时如何忽略 cloudbuild.yaml 中的“找不到图像”错误? - How to ignore "image not found" error in cloudbuild.yaml when deleting images from the artifact registry? Google App 引擎不读取 cloudbuild.yaml 文件 - Google App engine dosen't read the cloudbuild.yaml file 在 Gitlab-ci.yaml 管道中使用 spring-boot:build-image 创建 docker 镜像 - Using spring-boot:build-image in Gitlab-ci.yaml Pipeline to create a docker image 如何使用 buildspec.yml 在 AWS CodePipeline 中从 Dockerfile 构建图像,然后推送到 ECR? - How to build Image from Dockerfile in AWS CodePipeline using buildspec.yml, and then push to ECR? 服务帐户无法将 Docker 图像推送到 Google Artifact Registry - Service Account Unable to Push Docker Image to Google Artifact Registry FCM 推送通知 - 图片不推送 - FCM push notification - image not push 图片未显示在推送通知中 - Image not showing in push notification 使用 Google Cloud Vision 进行图像分类 API - Image Classification Using Google Cloud Vision API 您知道配置云运行以从 cloudbuild.yaml 设置 cloudsql 的任何方法吗? - Do you know any way of configuring cloud run to set a cloudsql from a cloudbuild.yaml?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM