This guide will show you how to deploy Cohere’s Toolkit on Google Cloud.
Note that this guide will not set up IAM policies for you on GCP. Both the toolkit-backend
and toolkit-frontend
containers are deployed with the allow-unauthenticated
option to help you deploy an MVP faster. Additionally, the CORSMiddleware
used in src/backend/main.py
allows all origins by default. For better security, replace the wildcard with the frontend container after deploying it.
To start, ensure you have all the required APIs enabled. The deployment will require the following APIs enabled:
To deploy from Cloud Build to Cloud Run, you will need to grant the Cloud Run Admin and Service Account User roles to your Cloud Build service account.
Service Account permissions
panel, set the status of the Cloud Run Admin
role to ENABLED.Your Cloud Build settings should now have Cloud Run and Service Accounts set to ENABLED.
Cloud SQL
in the top search bar, then select Create Instance
> Choose PostgreSQL
.toolkit-db
) and a password for the default postgres
user.PostgreSQL 14
database version.Enterprise > Sandbox
, and modify this later if needed.Create Instance
, which should take a couple of minutes for your database to be set up.Databases
> Create Database
, and create a new database (e.g., toolkit
).Connections
and select the Networking
tab. Click Add A Network
and add any name for it, along with the IP value of 0.0.0.0/0
.Run the following command:
gcloud auth login
Authenticate and select the project you provisioned the PostgreSQL database in.
Open the cloudbuild.yaml
file located in the root of this project. You will have several variables to fill in the substitutions
section:
us-central1
).postgresql://USERNAME:PASSWORD@HOST:PORT/DB_NAME
. The HOST
value is the public IP address of your provisioned PostgreSQL database, and the default PORT
is 5432. Use the username and password pair you set when creating your SQL instance. For example: postgresql://myuser:mypassword@<your-db-public-ip-address>:5432/toolkit
.Once completed, run the following command:
gcloud builds submit --region=<YOUR_GCP_REGION>
This should build the Docker images, push them to the Container Registry, and finally deploy them to Cloud Run. If you encounter any issues, ensure the substitution variables are correctly set.
After deploying the Cloud Run containers, it is recommended to set the minimum number of containers to 1 for both the frontend and backend containers to avoid any cold starts.
You are now done setting up Cohere’s Toolkit on Google Cloud!
Note that because Google Cloud Run containers are stateless and do not support Docker volumes, the file storage mechanism is not available for GCP deployments out of the box. Therefore, uploaded files to the Toolkit will be erased if your containers restart.
To get around this limitation, you will need to implement your own file storage system logic using Google Cloud Storage (or any other file storage system).