I cannot seem to run python3 manage.py makemigrations
on gcr.io/google-appengine/exec-wrapper
. It always claims python: not found. And it has been install in the docker image.
Here is the step
- id: 'migrate'
name: 'gcr.io/google-appengine/exec-wrapper'
args: ['-i', 'gcr.io/${_PROJECT_ID}/${_SERVICE}',
'-s', '${_PROJECT_ID}:${_REGION}:${_INSTANCE_NAME}',
'-e', '_PROJECT_ID=${_PROJECT_ID}',
'-e', 'SECRET_KEY=${_SECRET_KEY}',
'--', 'sh','.cloudbuild/django_migrate.sh']
The error itself says that python was not found when you submitted your Cloud build job using the build step you have provided here. First check if python is installed by running the command : python3 –version / python –version If you get an output with version 3.x, then python3 is successfully installed, if you get an output below python3.x, then you need to upgrade your python version to python3.
You have used this GitHub repo as a source for your build. I am predicting the issue is in the last line in your build step.
‘--’ should be the command you want to run, in your case it should be python3 manage.py makemigrations
(database migrations), you have used '--', 'sh','.cloudbuild/django_migrate.sh'
same as in the GitHub repo here.
The cloudbuild/django_migrate.sh is a script that has the following commands:
python manage.py migrate,
python manage.py loaddata sampledata ,
python manage.py collectstatic –noinput
but not python3 manage.py makemigrations. So when you are running the script as the last step of your build job, it builds fine but it doesn’t recognise python3 manage.py makemigrations command as it was neither specified in your build step nor it was there in your sh script.
Try with the below config :
steps:
- id: 'migrate'
name: gcr.io/google-appengine/exec-wrapper
args:
[ '-i', # The image you want to connect to the db from
'gcr.io/${_PROJECT_ID}/${_SERVICE}’,
'-s', # The postgres instance
'${_PROJECT_ID}:${_REGION}:${_INSTANCE_NAME}’,
'-e', # Get your secrets here...
'GCLOUD_ENV_SECRET_NAME=${_GCLOUD_ENV_SECRET_NAME}',
'--', # And then the command you want to run, in my case a database migration
'python3', 'manage.py', 'makemigrations',
]