Before you begin
- Complete the previous section of the tutorial, .
- Make sure that you have the following installed on your local machine:
- Clone the
movr-flaskrepository. We’ll reference the source code in this repository throughout the tutorial.
Set up a demo multi-region CockroachDB cluster
For debugging and development purposes, you can use the command. This command starts up a secure, nine-node demo cluster.-
To set up the demo multi-region cluster, run
cockroach demo, with the--nodesand--demo-localityflags. The localities specified below assume GCP region names.Keep this terminal window open. Closing it will shut down the demo cluster. -
Open another terminal window. In the new window, run the following command to load
dbinit.sqlto the demo database. This file contains themovrdatabase schema that we covered in . -
In the demo cluster terminal, verify that the database schema loaded properly:
In production, you want to start a secure CockroachDB cluster, with nodes on machines located in different areas of the world. For instructions on deploying a multi-region CockroachDB cluster for this application, using CockroachDB Standard, see .
Set up a virtual development environment
For debugging, usepipenv, a tool that manages dependencies with pip and creates virtual environments with virtualenv.
-
Run the following command to initialize the project’s virtual environment:
pipenvcreates aPipfilein the current directory, with the requirements needed for the app. -
Run the following command to install the packages listed in the
Pipfile: -
Activate the virtual environment:
From this shell, you can run any Python 3 application with the required dependencies that you listed in the
Pipfile, and the environment variables that you listed in the.envfile. You can exit the shell subprocess at any time with a simpleexitcommand. -
To test out the application, you can run the server file:
- Navigate to the URL provided to test out the application. By default, this should be http://127.0.0.1:5000/.
In production, you want to containerize your application and deploy it with a deployment orchestration tool, like Kubernetes, or with a serverless deployment service, like Google Cloud Run. We cover deploying the application with Google Cloud Run in .

