Skip to content

Commit

Permalink
refactor deployment scripts and updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitDherin committed May 29, 2024
1 parent d88fe67 commit 6c3de47
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
1 change: 1 addition & 0 deletions scaffolds/app_engine/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ tests:

.PHONY: deploy
deploy: clean
./scripts/create_app.sh
./scripts/deploy.sh

.PHONY: run
Expand Down
34 changes: 22 additions & 12 deletions scaffolds/app_engine/README.md
Original file line number Diff line number Diff line change
@@ -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`

6 changes: 3 additions & 3 deletions scaffolds/app_engine/app.yaml
Original file line number Diff line number Diff line change
@@ -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: "<YOUR_BUCKET>"
LOCATION: "us-central1"
PROJECT: "dherin-dev"
PROJECT: "<YOUR_PROJECT>"
4 changes: 2 additions & 2 deletions scaffolds/app_engine/scripts/config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PROJECT="dherin-dev"
PROJECT="<YOUR_PROJECT>"
LOCATION="us-central1"
BUCKET="dherin-dev"
BUCKET="<YOUR_BUCKET>"

# Compute various paths from the ROOT_DIR
ROOT_DIR="$(dirname $(cd $(dirname $BASH_SOURCE) && pwd))"
Expand Down
8 changes: 8 additions & 0 deletions scaffolds/app_engine/scripts/create_app.sh
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 6c3de47

Please sign in to comment.