简体   繁体   English

Cloud Build Docker 未构建

[英]Cloud Build Docker not building

I am trying to build an image using google cloud build for my GKE.我正在尝试使用 google cloud build 为我的 GKE 构建图像。 Locally I can build images using this command:我可以在本地使用此命令构建图像:

docker build -t backend .
docker  tag backend  gcr.io/project-id/backend:v15.8
docker  push  gcr.io/project-id/backend:v15.8

And it works fine but when I am trying to use:它工作正常但是当我尝试使用时:

steps:
- name: "gcr.io/cloud-builders/docker"
  args: ["build", "-t", "gcr.io/project-id/backend:v15.8", "."]
  # push container image
- name: "gcr.io/cloud-builders/docker"
  args: ["push", "gcr.io/project-id/backend:v15.8"]

This code is building the image but I don't know why some of the files it misses.这段代码正在构建图像,但我不知道为什么它会遗漏一些文件。 I have several files in.gitignore.我在 .gitignore 中有几个文件。

I can build an image but it is not the same as I am building an image from command locally.我可以构建一个图像,但它与我在本地从命令构建图像不同。 When I am deploying it to my GKE one file is missing which is in.gitignore file.当我将它部署到我的 GKE 时,缺少一个文件,即 in.gitignore 文件。 What do I need to do in order to achieve my goal我需要做什么才能实现我的目标

As mentioned by @JohnHanley on the comments, the use of .gcloudignore is recommended in cases like this.正如@JohnHanley 在评论中提到的,在这种情况下建议使用.gcloudignore You should ignore the .gitignore file inside the .gcloudignore to be able to use the required file.您应该忽略.gcloudignore中的.gitignore文件,以便能够使用所需的文件。

So if you add this a line with .gitignore to your .gcloudignore it will fix the issue you are facing.因此,如果您将带有.gitignore的一行添加到您的.gcloudignore中,它将解决您面临的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Cloud Run - Docker building container building but not accessible - Google Cloud Run - Docker building container building but not accessible Google Cloud Build Docker build-arg 不受尊重 - Google Cloud Build Docker build-arg not respected 调试在构建第一个服务时冻结的 docker-compose 构建 - Debugging docker-compose build that freezes on building first service 如何在 GCP Cloud Build 的 Terraform Docker Provider 中构建和推送 docker 映像 - How to build and push a docker image in a Terraform Docker Provider by GCP Cloud Build 在 docker 构建中不会发生云构建上的构建类型错误 - Getting a build type error on cloud build that doesn't happen in docker build Cloud Run - BUILD_DOCKER_UNKNOWN // 无法导入 python - Cloud Run - BUILD_DOCKER_UNKNOWN // cant import python 如何在谷歌云构建中将参数传递给 docker run - How to pass parameters to docker run in google cloud build Docker:构建 Debian 11 镜像,其中包含 Python 和 Google Cloud SDK - Docker: Build Debian 11 image, with Python and Google Cloud SDK in it 默认情况下,Google Cloud Build 是否在步骤之间保留 docker 张图像? - Does Google Cloud Build keep docker images between steps by default? Google Cloud Build & Docker “Cloud Builder” - 以前工作的构建现在提供 137 状态代码 - Google Cloud Build & Docker "Cloud Builder" - builds that previously worked now give 137 status code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM