In this guide, we'll walk through the process of deploying Canopy on Google Cloud Platform (GCP).
The steps include setting up GCP, creating a Docker repository, pulling and tagging the Canopy image, and finally deploying it using Google Cloud Run.
Before you begin, make sure you have the following installed:
and make sure you have a project set up in GCP.
Open your terminal and run the following commands:
# Authenticate with your Google Cloud account
gcloud auth login
# Set the GCP project
gcloud config set project {project-name}If you have a docker repository in GCP you can skip this step. If not run the following commands to create one:
# Create a Docker repository on GCP
gcloud artifacts repositories create {repository-name} \
--repository-format docker \
--location us-west1 \
--description "Docker repository for storing images of Canopy."We'll start by fetching the official Canopy image from GitHub Packages, and then we'll apply a tag to prepare the image
for pushing it to Google Cloud Platform (GCP). You can access all the available images here.
# Pull the Canopy Docker image
docker pull ghcr.io/pinecone-io/canopy:{canopy-version}
# Tag the image for GCP repository
docker tag ghcr.io/pinecone-io/canopy:{canopy-version} us-west1-docker.pkg.dev/{project-name}/{repository-name}/canopy:{canopy-version}# Configure Docker to use GCP credentials
gcloud auth configure-docker us-west1-docker.pkg.dev# Push the Canopy Docker image to GCP repository
docker push us-west1-docker.pkg.dev/{project-name}/{repository-name}/canopy:{canopy-version}Before running the following command make sure to create a .env file and include the environment variables mentioned
in README.md.
OPENAI_API_KEY={open-api-key}
PINECONE_API_KEY={pinecone-api-key}
INDEX_NAME={index-name}
# Other necessary environment variables if needed
To create a new index in Pinecone, run the following command:
docker run --env-file .env ghcr.io/pinecone-io/canopy:{canopy-version} yes | canopy newTo upsert documents into Pinecone run:
docker run --env-file .env ghcr.io/pinecone-io/canopy:{canopy-version} yes | canopy upsert {parquet-file.parquet}To deploy Canopy on GCP, run the following command:
# Deploy Canopy on Google Cloud Run
gcloud run deploy canopy \
--image us-west1-docker.pkg.dev/{project-name}/{repository-name}/canopy:{canopy-version} \
--platform managed \
--region us-west1 \
--min-instances 1 \
--port 8000 \
--allow-unauthenticated \
--set-env-vars $(grep -v '^#' .env | tr '\n' ',' | sed 's/,$//')Congratulations! You have successfully deployed Canopy on Google Cloud Run.
You should now see an output similar to this:
Deploying container to Cloud Run service [canopy] in project [project-name] region [us-west1]
✓ Deploying new service... Done.
✓ Creating Revision...
✓ Routing traffic...
✓ Setting IAM Policy...
Done.
Service [canopy] revision [canopy-00001-6cf] has been deployed and is serving 100 percent of traffic.
Service URL: https://canopy-bxkpka-uw.a.run.app
From your terminal run the following command using the service url you have received from GCP:
curl {service-url}/v1/healthIf you see the following output your deployment is completed successfully!
{"pinecone_status":"OK","llm_status":"OK"}If you have an issue accessing the server, make sure you have an index. To create an index, follow Step 7.
There are several options to interact with your service.
If you want to use Canopy's built-in Chat CLI, you can run:
docker run --env-file .env ghcr.io/pinecone-io/canopy:{canopy-version} canopy chatYou can use any OpenAI compatible chat UI to interact with the newly deployed server.
Examples:
You can also use OpenAI's python client to interact with the server. For more information, see Migrating Existing Application to Canopy