[英]Google Cloud Build Error: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
Note: There is a similar post regarding this issue but it involves a CI/CD workflow and a considerably more complicated Dockerfile.注意:有一篇关于此问题的类似帖子,但它涉及 CI/CD 工作流程和相当复杂的 Dockerfile。 The solutions presented do not seem to apply to my situation.
提出的解决方案似乎不适用于我的情况。
Per Google documentation I am attempting to build an image by running gcloud run deploy
in the directory where the files mentioned in my Dockerfile are located.根据Google 文档,我试图通过在 Dockerfile 中提到的文件所在的目录中运行
gcloud run deploy
来构建映像。 The Dockerfile appears as: Dockerfile 显示为:
FROM python:3.9-alpine
WORKDIR /app
COPY main.py /app/main.py
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt
CMD ["python3", "main.py"]
I receive a message that the build failed, and when checking the logs I see the following:我收到一条构建失败的消息,在检查日志时,我看到以下内容:
starting build "..."
FETCHSOURCE
Fetching storage object: gs://my-app_cloudbuild/source/....
Copying gs://my-app_cloudbuild/source/...
/ [0 files][ 0.0 B/ 1.5 KiB]
/ [1 files][ 1.5 KiB/ 1.5 KiB]
Operation completed over 1 objects/1.5 KiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
Can anyone explain the reason for this error?谁能解释这个错误的原因? I suspect it has to do with how files are copied to the image, but I was able to build and run this container without problem on my local machine.
我怀疑这与文件如何复制到映像有关,但我能够在本地计算机上构建和运行这个容器而没有问题。 Any idea why this fails in Cloud Run Build?
知道为什么这在 Cloud Run Build 中失败了吗?
Running ls -la
in the directory where I ran gcloud run deploy
returns:在我运行
gcloud run deploy
的目录中运行ls -la
返回:
drwxr-xr-x 9 user staff 288 May 20 16:04 .
drwxr-xr-x 6 user staff 192 May 20 13:35 ..
drwxr-xr-x 14 user staff 448 May 20 16:06 .git
-rw-r--r-- 1 user staff 27 May 20 15:06 .gitignore
-rw-r--r-- 1 user staff 424 May 20 16:54 Dockerfile
-rw-r--r-- 1 user staff 3041 May 20 15:55 main.py
-rw-r--r-- 1 user staff 144 May 19 09:42 requirements.txt
drwxr-xr-x 6 user staff 192 May 19 09:09 venv
Contents of .gitignore
: .gitignore
的内容:
Dockerfile
venv
*.gz
*.tar
*.pem
Full console output when attempting two-step build (see comments):尝试两步构建时的完整控制台输出(见评论):
user@users-MacBook-Pro TwitterBotAQI % gcloud builds submit --tag gcr.io/missoula-aqi/aqi
Creating temporary tarball archive of 2 file(s) totalling 3.1 KiB before compression.
Some files were not included in the source upload.
Check the gcloud log [/Users/user/.config/gcloud/logs/2022.05.20/18.40.53.921436.log] to see which files and the contents of the
default gcloudignore file used (see `$ gcloud topic gcloudignore` to learn
more).
Uploading tarball of [.] to [gs://missoula-aqi_cloudbuild/source/1653093653.998995-48d4ba15b3274455a21e16b7abc7d65b.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/missoula-aqi/locations/global/builds/0c22d976-171e-4e7b-92d8-ec91704d6d52].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/0c22d976-171e-4e7b-92d8-ec91704d6d52?project=468471228522].
------------------------------------------------------------------------------------ REMOTE BUILD OUTPUT -------------------------------------------------------------------------------------
starting build "0c22d976-171e-4e7b-92d8-ec91704d6d52"
FETCHSOURCE
Fetching storage object: gs://missoula-aqi_cloudbuild/source/1653093653.998995-48d4ba15b3274455a21e16b7abc7d65b.tgz#1653093655000531
Copying gs://missoula-aqi_cloudbuild/source/1653093653.998995-48d4ba15b3274455a21e16b7abc7d65b.tgz#1653093655000531...
/ [1 files][ 1.5 KiB/ 1.5 KiB]
Operation completed over 1 objects/1.5 KiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BUILD FAILURE: Build step failure: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
ERROR: (gcloud.builds.submit) build 0c22d976-171e-4e7b-92d8-ec91704d6d52 completed with status "FAILURE"
I had added Dockerfile
to .gitignore
as it contained API keys stored as environment variables.我已将
Dockerfile
添加到.gitignore
,因为它包含存储为环境变量的 API 密钥。 Removing Dockerfile
from .gitignore
resolved the issue.从
.gitignore
中删除Dockerfile
解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.