Skip to content

Instantly share code, notes, and snippets.

@magdairis
Created September 21, 2020 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magdairis/6fc0425f8efe0d3d2c5023ecfc716930 to your computer and use it in GitHub Desktop.
Save magdairis/6fc0425f8efe0d3d2c5023ecfc716930 to your computer and use it in GitHub Desktop.
SHOP-backend-documentation

Setting up DB to be pushed and deployed easy peasy

Log in to Google Cloud console

  • Bearjam commerce project
  • Database instance can have multiple databases
    • so we don't have to pay for multiple users

Set up Cloud SQL proxy PostgreSQL

  • Quickstart for local testing
  • Cloud SQL Viewer
  • Use a Postgres client to connect to localhost
  • Set password for Postgres user
  • Postgres interface in terminal

Three environments

  • Development
  • Staging
  • Production aka Master

(a bit like github)

Deploy to app enginge, w/o worrying about the DB Create a build trigger that deploys the code to app engine on push to master/staging There are two files we need to add to our code at this point

  • add app.yaml and cloudbuild.yaml

Create trigger in Gcloud Base Cloud build config file

  • File type - cloud build yaml or json - cloudbuild.yaml
  • Follow documentation for permissions, etc.
  • Once created, run the trigger

Files needed

staging.app.yaml staging.cloudbuild.yaml master.app.yaml master.cloudbuild.yaml

steps:
  - name: gcr.io/cloud-builders/gcloud
    entrypoint: "bash"
    args: [
        "-c",
        "gcloud secrets versions access latest --secret=$REPO_NAME-app-yaml-$BRANCH_NAME
        --format='get(payload.data)' | tr '_-' '/+' | base64 -d > app.yaml",
      ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment