diff --git a/scaffolds/app_engine/Makefile b/scaffolds/app_engine/Makefile index e35de72e..1d08efd5 100644 --- a/scaffolds/app_engine/Makefile +++ b/scaffolds/app_engine/Makefile @@ -23,6 +23,7 @@ tests: .PHONY: deploy deploy: clean + ./scripts/create_app.sh ./scripts/deploy.sh .PHONY: run diff --git a/scaffolds/app_engine/README.md b/scaffolds/app_engine/README.md index 516be00c..0b23fc18 100644 --- a/scaffolds/app_engine/README.md +++ b/scaffolds/app_engine/README.md @@ -1,41 +1,51 @@ -# Developpment Workflow +# Development Workflow +## Local development -## Local developpment +The workflow described here works from CloudShell or any node with the [gcloud CLI](https://cloud.google.com/sdk/docs/install) has been properly installed and authenticated. -The workflow described here works from CloudShell or any node with the gcloud SDK authenticated -,that is, you can do the developpement fully locally on your laptop, which is the preferred -development environment. +This means that you can develop your application fully locally on your laptop for example, as long as you have run `make auth` after installing the [gcloud CLI](https://cloud.google.com/sdk/docs/install) on it. + +The first step is to add your `PROJECT` and `BUCKET` names in the following files: +* `./scripts/config.sh` +* `app.yaml` + +For local development, install then the gcloud CLI following [these instructions](https://cloud.google.com/sdk/docs/install). + +Make sure to accept upgrading Python to 3.10 if prompted, then authenticate for local development by running: -For local development, first install the Google SDK following these instructions(https://cloud.google.com/sdk/docs/install#mac). -Make sure to accept upgrading Python to 3.10 when prompted, then authenticate for local development by running: ```bash make auth ``` -Then create and populate the virtual environment: +The second step is to create and populate the virtual environment with + ```bash make venv ``` +After this step you should find a new folder called `venv` containing the virtual environment. -To run the tests: +At this point you should already be able to run the tests by running ```bash make tests ``` -Run the answernaut locally with +To run the app locally, simply run ```bash make run ``` -Deploy on AppEngine +At last to deploy the application on AppEngine run ```bash make deploy ``` -## Developpement workflow +**Note:** `make clean` will remove all the built artifacts as long as the virtual environment created by `make venv`. This target is invoked by `make deploy` so that the built artifacts are not uploaded to AppEngine. The down-side is that the virtual environment will need to be recreated after each deployment. + +## Development workflow 1. Edit the code 1. Run the tests with `make tests` 1. Test the app local with `make run` 1. Deploy the app on AppEngine with `make deploy` + diff --git a/scaffolds/app_engine/app.yaml b/scaffolds/app_engine/app.yaml index cc7bb2bb..7ae895f5 100644 --- a/scaffolds/app_engine/app.yaml +++ b/scaffolds/app_engine/app.yaml @@ -1,10 +1,10 @@ runtime: python310 -entrypoint: gunicorn -b :$PORT asl.server:app +entrypoint: gunicorn -b :$PORT app.server:app runtime_config: operating_system: "ubuntu22" env_variables: - BUCKET: "dherin-dev" + BUCKET: "" LOCATION: "us-central1" - PROJECT: "dherin-dev" + PROJECT: "" diff --git a/scaffolds/app_engine/scripts/config.sh b/scaffolds/app_engine/scripts/config.sh index 58dc83a3..802bd7d6 100644 --- a/scaffolds/app_engine/scripts/config.sh +++ b/scaffolds/app_engine/scripts/config.sh @@ -1,6 +1,6 @@ -PROJECT="dherin-dev" +PROJECT="" LOCATION="us-central1" -BUCKET="dherin-dev" +BUCKET="" # Compute various paths from the ROOT_DIR ROOT_DIR="$(dirname $(cd $(dirname $BASH_SOURCE) && pwd))" diff --git a/scaffolds/app_engine/scripts/create_app.sh b/scaffolds/app_engine/scripts/create_app.sh new file mode 100755 index 00000000..0e5435ba --- /dev/null +++ b/scaffolds/app_engine/scripts/create_app.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +. $(cd $(dirname $BASH_SOURCE) && pwd)/config.sh + +gcloud app describe --project=$PROJECT 2> /dev/null || { + echo "No App on AppEngine existing. Creating one." + gcloud app create --region=$LOCATION --project=$PROJECT +}