0

我尝试将应用程序部署到 GCP 中的云运行,它使用 docker 文件成功执行。现在,我正在使用 cloudbuild.yaml 设置 CI/CD。我将 repo 镜像到 CSR 并创建了一个 cloudbuild 服务并将 cloudbuild.yaml 放在我的存储库。从 cloudbuild 执行时,会引发以下错误。

    Status: Downloaded newer image for gcr.io/google.com/cloudsdktool/cloud-sdk:latest
gcr.io/google.com/cloudsdktool/cloud-sdk:latest

Deploying...
Creating Revision...failed
Deployment failedERROR: (gcloud.run.deploy) Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. 

Docker 文件附在下面:

#pulls python 3.7’s image from the docker hub
FROM python:alpine3.7
#copies the flask app into the container
COPY . /app
#sets the working directory
WORKDIR /app
#install each library written in requirements.txt
RUN pip install -r requirements.txt
#exposes port 8080
EXPOSE 8080
#Entrypoint and CMD together just execute the command
#python app.py which runs this file
ENTRYPOINT [ "python" ]
CMD [ "app.py" ]

cloudbuild.yaml:

 steps:
 # Build the container image
 - name: 'gcr.io/cloud-builders/docker'
   args: ['build', '-t', 'gcr.io/projectid/servicename', '.']
 # Push the container image to Container Registry
 - name: 'gcr.io/cloud-builders/docker'
   args: ['push', 'gcr.io/projectid/servicename']
 # Deploy container image to Cloud Run
 - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
   entrypoint: gcloud
   args:
   - 'run'
   - 'deploy'
   - 'phase-2'
   - '--image'
   - 'gcr.io/projectid/servicename'
   - '--region'
   - 'us-central1'
   - '--platform'
   - 'managed'
 images:
 - 'gcr.io/projectid/servicename'.  


 
4

1 回答 1

0

OP 解决了问题,如评论中所示:

问题解决了。这是因为python兼容性问题。我应该在docker文件中使用pip3和python3。我认为gcr.io图像与python3兼容。

于 2021-07-20T14:39:16.387 回答