Deployment of the Python-Django app to GCP

Note: Started with a reinstall of Mac OS X Mojave for a clean start:

STEPS:

  1. Installed pip (package manager)
    • https://www.youtube.com/watch?v=yBdZZGPpYxg
  2. First attempt to setup Django w/ PostgreSQL
    • https://docs.djangoproject.com/en/2.2/topics/install/
      "In addition to a database backend, you’ll need to make sure your Python database bindings are installed. If you’re using PostgreSQL, you’ll need the psycopg2 package."
      • http://initd.org/psycopg/download/
      • Ran into an error!
  3. Downloading PostgreSQL with GUI Instead
    • https://www.postgresql.org/download/macosx/
    • https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
      • Includes (PostgreSQL server, pgAdmin (for managing and developing databases), and StackBuilder (package manager for download/installing additional PostgreSQL tools and drivers)
      • Downloading Version 11.4 for Mac OS X
      • Success!!
    • Back to the GCP documentation "Running Django in the App Engine flexible environment" https://cloud.google.com/python/django/flexible-environment
      • Downloaded the Google Cloud SDK command line tools
      • Creating the Django project
        https://docs.djangoproject.com/en/2.2/intro/tutorial01/
        Question... "Don't I need a virtual environment?"
        https://www.youtube.com/watch?v=N5vscPTWKOk
        The answer is YES
      • Installing/Setting up the virtual environment:
        https://cloud.google.com/python/setup#installing_and_using_virtualenv
      • Initializing your Cloud SQL instance
        Run 3 different commands then use another terminal window
      • Set up the project files
        settings.py
        static folder
        templates folder
        urls.py
        urls.py (2)
        views.py
        app.yaml
        requirements.txt (command to create: pip list --format freeze > requirements.txt)
      • Download/install all tools into environment (see image below)

    technical-details (1)

    Helpful links

    https://stackoverflow.com/questions/21079820/how-to-find-pg-config-path

    Screenshot of environment

    Deployment was successful in the 4th trial!

    image

1 Like