Skip to content

Deploying the project on a GCP VM

Ngan Vu edited this page Dec 10, 2018 · 2 revisions

Once you have this project running on your local machine, you may want to deploy it so that it is available on the internet for anyone to use!

Things can be a little bit complicated when you first try to deploy the project. Follow the steps below:

Configure VPC network of Google Cloud Platform

From the main menu of GCP, choose "VPC network". The steps below are all on this page.

1. Set external IP address

Click on "External IP addresses". Change the type of IP address of your project to "Static" so that it does not change every time you restart your VM.

2. Add firewall rules

Since we are using a Flask app, we need more firewall rules to allow traffic on HTTP (port 80), HTTPS (port 443), and Flask apps (port 5000). Add the following firewall rules.

3. Make sure you have a default internet gateway

Your VM should by default has a default internet gateway (with the generic destination IP range of 0.0.0.0/0). If not, add one.

Run the Flask app

Once you have finished all the steps above, you can run the Flask app with the following command (note the host flag):

FLASK_APP=app.py flask run --host=0.0.0.0

Your webpage is now available at the external IP address in step 1 above, at port 5000!