Visit https://console.cloud.google.com/getting-started
Be sure to setup billing too.
Navigation Menu -> IAM & Admin -> Settings
Press that button at top right.
You may use this repo just for testing. A quick way to copy files and folders into the google cloud.
git clone https://github.com/fsmosca/rflask.git
cd rflask
This is only local with respect to the machine in GCP that we are using. This is different when we actually deploy our app.
python -m venv venv
source venv/bin/activate
To test if the contents of our requirements.txt file is right.
pip install -r requirements.txt
We are not deploying for production yet. Just testing the virtual environment.
gunicorn main:app
You should see the following from the given url.
"Hello, world!"
Send control+c in the shell to exit.
Now let us create an app for production. This is the real deal that we are up to.
gcloud app create
The app.yaml is using flexible environment, you can open the app.yaml file. Flexible uses a container. There are comments in app.yaml file. Read the items in the reference section too.
gcloud app deploy --appyaml=app.yaml
This is our app.yaml
.
runtime: python
# F1 = 2 workers (default), F2 = 4 workers
instance_class: F1
env: flex
# -w 2 sets gunicorn number of workers
# The number of workers you specify should match the instance class of your App Engine app:
entrypoint: gunicorn -b :$PORT -w 2 main:app
runtime_config:
operating_system: "ubuntu22"
runtime_version: "3.11"
Be sure to shutdown your project if you are just testing it.
Even better is to delete the project so that it is disconnected from the billing.
- The
app.yaml
is using flexible environment. Attempts to use standard environment did not work so far. - We use gunicorn in entry point at
app.yaml
, so we need gunicorn inrequirements.txt