0

I have deployed django application in app engine flexible.

I'm able to run migrations using cloud_sql_proxy. But i want to add migrate step as a part of deployment. Where do i specify that in app.yaml file ? Also tried

gcloud beta app gen-config --custom

Which creates docker file. on adding migration command in docker file, recieved the following error:

could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?

Settings.py

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'test',
'USER': 'test',
'PASSWORD': 'password',
'PORT': '5432',
'HOST': 'connection-name',
}}

app.yaml

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT wsgi

beta_settings:
  cloud_sql_instances: connection-name

runtime_config:
  python_version: 3

Please suggest approach to add migrate command.

Manasa
  • 130
  • 2
  • 10

1 Answers1

1

You can't add migrate command as part of the deployment process. The app.yaml file just for app engine related configuration. So that what you can do is to connect with your Google Cloud SQL Instance in the local machin and run the migrate command.

The other options is to setup continuous integration. You can visit this link to get the idea about how to setup CI/CD on Travis.

Raja Simon
  • 10,126
  • 5
  • 43
  • 74
  • Yeah docker is perfect options for gcloud appengine. But if you wanted to use this then you have to use gcloud custome runtime. Using the custom runtime you can mention the docker image on the dockerfile, and gcloud deploy will take care of the rest. – Raja Simon Oct 31 '18 at 06:32
  • yes, as mentioned i tried docker as well. But getting following error. Is the server running on host "Instance IP" and accepting TCP/IP connections on port 5432? – Manasa Oct 31 '18 at 06:46
  • @Manasa Can you try with this answer https://stackoverflow.com/a/48431559/3762142 – Raja Simon Oct 31 '18 at 07:43
  • I wish I can help you more to debug this problem unfortunately the information provided by you is very less and I trying to understand the context here. Forgot about the cloud instance first, and can you able to docker migrate with you local postgresql/mysql database connection? If that's worked. And then we can debug further with one by one. – Raja Simon Oct 31 '18 at 11:23