Reputation: 220
When trying to deploy my fastapi python service (on App Engine), I'm running into the following error in the deploy step:ERROR: gcloud crashed (OSError): [Errno 2] No such file or directory: '/workspace/env/bin/python3.7'
I'm starting the deploy/build from my local machine with the following command: gcloud builds submit --config config/cloudbuild/deploy.yaml --project $_PROJECT
.
Am I doing something wrong, or could it be something wrong with the gcloud builder? I've tried with both google cloud sdk version 274.0.1 and 300.0.0.
deploy.yaml
:
steps:
# Install gcc
- name: 'python:3.7'
id: 'install-dependencies'
entrypoint: sh
args:
- -c
- apt update && apt-get -y install gcc && python -m pip install -r requirements.txt -t lib
# Run tests
- name: 'python:3.7'
id: 'test'
env:
- PYTHONPATH=lib
entrypoint: python3
args: ['-m', 'pytest']
# Deploy
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy', '--project', '$PROJECT_ID']
timeout: '1200s'
app.yaml
:
runtime: python37
service: my-service
instance_class: F2
entrypoint: gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker
handlers:
- url: /.*
script: auto
secure: always
inbound_services:
- warmup
automatic_scaling:
min_instances: 1
min_idle_instances: 1
max_instances: 2
max_idle_instances: 1
Build output:
...
Finished Step #1 - "test"
Starting Step #2
Step #2: Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #2:
Step #2: ***** NOTICE *****
Step #2:
Step #2: Official `cloud-sdk` images, including multiple tagged versions across multiple
Step #2: platforms, can be found at
Step #2: https://github.com/GoogleCloudPlatform/cloud-sdk-docker.
Step #2:
Step #2: Suggested alternative images include:
Step #2:
Step #2: gcr.io/google.com/cloudsdktool/cloud-sdk
Step #2: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
Step #2: gcr.io/google.com/cloudsdktool/cloud-sdk:debian_component_based
Step #2: gcr.io/google.com/cloudsdktool/cloud-sdk:slim
Step #2:
Step #2: Please note that the `gcloud` entrypoint must be specified when using these
Step #2: images.
Step #2:
Step #2: ***** END OF NOTICE *****
Step #2:
Step #2: Services to deploy:
Step #2:
Step #2: descriptor: [/workspace/app.yaml]
Step #2: source: [/workspace]
Step #2: target project: [my-project]
Step #2: target service: [my-service]
Step #2: target version: [20200710t134102]
Step #2: target url: [https://my-service.uc.r.appspot.com]
Step #2:
Step #2:
Step #2: Do you want to continue (Y/n)?
Step #2: Beginning deployment of service [my-service]...
Step #2: Created .gcloudignore file. See `gcloud topic gcloudignore` for details.
Step #2: ERROR: gcloud crashed (OSError): [Errno 2] No such file or directory: '/workspace/env/bin/python3.7'
Step #2:
Step #2: If you would like to report this issue, please run the following command:
Step #2: gcloud feedback
Step #2:
Step #2: To check gcloud for common problems, please run the following command:
Step #2: gcloud info --run-diagnostics
Finished Step #2
ERROR
ERROR: build step 2 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1
Upvotes: 1
Views: 6449
Reputation: 40051
Cloud Build is essentially a pipeline of containers applied to a shared file system (/workspace
).
The only state that's available to you is through /workspace
.
Each step implicitly mounts /workspace
.
Your step #0 is mostly redundant. It applies apt
to the container image created in step #0 (and may as a side-effect) update the mounted /workspace
too but these updates are discarded (except the mutations to /workspace
when that step completes. You shouldn't try to update /workspace
with e.g. Python module installs that you intend to use in subsequent steps.
I suspect you're installing pytest
with the requirements.txt
in step #0 but this doesn't correctly apply to step #1's use of pytest
. What you should do is create a container that includes pytest
so that you can run pytest
in this step.
If you discard everything except step #2, it should work (it does for me).
If you wish to run pytest
you'll need a container image that includes it so that you can run this isolated step before deployment.
Upvotes: 2