Development can be done in Docker without any external dependencies using docker-compose.
For the first time running, you can bootstrap the local development environment with bin/bootstrap.sh
.
After that, you can manage the environment with standard docker-compose commands. A few of the more common commands are listed below.
Action | Command |
---|---|
Bootstrap environment | $ bin/bootstrap.sh |
Start environment | $ docker-compose start |
Stop environment | $ docker-compose stop |
Attach to logs | $ docker-compose logs -f |
Python shell | $ docker-compose exec django ./manage.py shell |
Apply DB Migrations | $ docker-compose exec django ./manage.py migrate |
Make DB Migrations | $ docker-compose exec django ./manage.py makemigrations |
Destroy environment | $ docker-compose down -v |
If you prefer not to develop with Docker, you can run the app natively on your system.
$ brew install python pipenv
$ brew install mysql
1$ brew install mysql-connector-c
2$ export PIPENV_VENV_IN_PROJECT=1
$ pipenv sync --dev
$ pipenv run app_microservice/manage.py runserver
1 Make sure the MySQL service is running, and configure an appropriate database.
2There is a bug with the MySQL python bindings on Mac OSX. See: https://pypi.org/project/mysqlclient/
To install the pre-commit hooks that check and fix:
- trailing whitespaces
- file endings (forcing new lines)
- PE8 compliance
- style guide compliance
please run:
$ pipenv run pre-commit install
For VSCode, an appropriate settings.json
is shipped as part of this repository.
This project includes a GitHub workflow for deployment to Google Cloud Run. To do so, perform the following steps:
-
Create a new service account (SA) via: IAM & Admin > Service Accounts > Create Service Account
-
Grant permissions via IAM & Admin > IAM > Permissions > Edit SA (from above) > Add another role
- Service Account User
- Cloud Run Admin
-
Generate a service account key via IAM & Admin > Service Accounts > Actions > Create key > type: JSON
-
Add GitHub secrets
GCP_PROJECT_ID: <your-project>
GCP_SA_KEY: <JSON-contents-from-above>
-
Enable the Google Cloud Run Admin API
-
Deploy via GitHub Actions
-
Allow public access via Cloud Run >
app-api
service > Permissions > Add > members:allUsers
/ role:Cloud Run Invoker
This project relies on a relational database for permanently storing data. To provision such a database on Google Cloud:
-
Enable the Cloud SQL Admin API
-
Create a new Cloud SQL instance via: SQL > Create Instance > MySQL v8 with a public IP
-
Create a new database via: SQL > Select previously created instance > Databases > Create database
-
Update the
app.service.yaml
deployment specification accordingly:
- Environment variables starting with
DJANGO_DATABASE_
run.googleapis.com/cloudsql-instances
metadata annotation