- Python 3
- Cloud SQL Proxy
-
Create environment (This is only needed for the first time)
python3 -m venv venv
-
Activate environment
. venv/bin/activate
-
Install Flask and other dependencies locally (if you haven't)
pip install -r requirements.txt
-
Install and launch Cloud SQL Proxy
./cloud_sql_proxy -dir=/tmp/cloudsql -instances=yori_instance_name=tcp:3306
-
Launch server
env FLASK_APP=main.py DB_USER=username DB_PASS=password DB_NAME=database CLOUD_SQL_CONNECTION_NAME=yori_instance_name flask run
or if you want to enable network access to local server (especially when you are developing yori-view)
env FLASK_APP=main.py DB_USER=username DB_PASS=password DB_NAME=database CLOUD_SQL_CONNECTION_NAME=yori_instance_name flask run --host=0.0.0.0
If setting environments bothers you, write them in your dotfiles.
Before deploy to gcloud, you have to install gcloud sdk. (Install guide)
-
Create a
secret.yaml
(if you haven't) and set your own environment variable NOTICE: do not upload yoursecret.yaml
to repositoryenv_variables: CLOUD_SQL_CONNECTION_NAME: your-connection-name DB_USER: your-account DB_PASS: your-password DB_NAME: your-database SLACK_WEBHOOK_URL: slack-webhook-url
-
Deploy Command
gcloud app deploy