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