---
layout: default
title: Advanced (hybrid) setups
nav_order: 11
parent: Build your own Data Commons
include_scripts:
- /assets/js/customdc-doc-tabs.js
- /assets/js/user-supplied-variables.js
---
{: .no_toc}
# Advanced setups
This page covers hybrid setups that are not recommended for most use cases, but may be helpful for some custom Data Commons instances:
- [Running the data management container locally, and the service container in Google Cloud](#run-local). In this scenario, you store your input data locally, and write the output to Cloud Storage and Cloud SQL. This might be useful for users with very large data sets, that would like to cut down on output generation times and the cost of storing input data in addition to output data.
- [Running the service container locally, and the data management container in Google Cloud](#local-services). If you have already set up a data processing pipeline to send your input data to Google Cloud, but are still iterating on the website code, this might be a useful option.
- [Running the service container locally, and custom MCP instructions in Google Cloud](#instructions). If you're already using Google Cloud Storage but want to test the server locally, you can use this option.
## (Optional) Set common variable values for this page
If you would like to more easily copy and paste commands from this page, supply the values you've provided for Terraform for the following fields. The page will automatically populate all occurrences.
## Run the data management container locally and the service container in the cloud {#run-local}
This process is similar to running both data management and services containers locally, with a few exceptions:
- Your input directory will be the local file system, while the output directory will be a Google Cloud Storage bucket and folder.
- You must start the job with credentials to be passed to Google Cloud, to access the Cloud SQL instance.
Before you proceed, ensure you have [set up all necessary GCP services](deploy_cloud.md).
### Step 1: Set environment variables
To run a local instance of the data management container, you need to set all of the GCP-related environment variables in the `custom_dc/env.list` file.
1. Obtain the values output by Terraform scripts:
DB_PASS variable. It is in the form Your Data Commons namespace-datacommons-mysql-password.env.list file.gcloud run jobs describe JOB_NAME --region us-central1Secrets section of the output, note the name of the DB_PASS secret. It is in the form Your Data Commons namespace-datacommons-mysql-password.gcloud secrets versions access latest --secret=SECRET_ID
gs://GCS_BUCKET/FOLDER.
### Step 2: Run the data management Docker container
website root directory, run the following command:
./run_cdc_dev_docker.sh --container data
gcloud auth application-default login
website root directory, run the data container:
docker run \ --env-file $PWD/custom_dc/env.list \ -v INPUT_DIRECTORY:INPUT_DIRECTORY \ -e GOOGLE_APPLICATION_CREDENTIALS=/gcp/creds.json \ -v $HOME/.config/gcloud/application_default_credentials.json:/gcp/creds.json:ro \ gcr.io/datcom-ci/datacommons-data:stable>
./run_cdc_dev_docker.sh --container data --schema_update
docker run \ --env-file $PWD/custom_dc/env.list \ -v INPUT_DIRECTORY:INPUT_DIRECTORY \ -e GOOGLE_APPLICATION_CREDENTIALS=/gcp/creds.json \ -v $HOME/.config/gcloud/application_default_credentials.json:/gcp/creds.json:ro \ -e DATA_RUN_MODE=schemaupdate gcr.io/datcom-ci/datacommons-data:stable
DB_PASS variable. It is in the form Your Data Commons namespace-datacommons-mysql-password.gcloud run services describe SERVICE_NAME --region us-central1Secrets section of the output, note the name of the DB_PASS secret. It is in the form Your Data Commons namespace-datacommons-mysql-password.gcloud secrets versions access latest --secret=SECRET_ID
gcloud auth application-default login
website root directory, run the services container:
./run_cdc_dev_docker.sh --container service [--image IMAGE_CONTAINER_URL]
If you're using a custom-built image, the image container URL is required, in the form name:tag.
gcloud auth application-default login
docker run -it \
-p 8080:8080 \
-e DEBUG=true \
--env-file $PWD/custom_dc/env.list \
-e GOOGLE_APPLICATION_CREDENTIALS=/gcp/creds.json \
-v $HOME/.config/gcloud/application_default_credentials.json:/gcp/creds.json:ro \
IMAGE_CONTAINER_URL
The image container URL is the name and tag of a prebuilt or custom-built image.
gs://GCS_BUCKET/INSTRUCTIONS_FOLDER. For example, if your Cloud Storage bucket is named `mybucket` and the folder you created in it is called `instructions`, you would specify the following:
```
DC_INSTRUCTIONS_DIR=gs://mybucket/instructions
```
### Step 3: Restart the services container
Run the services container as in [step 2](#step2) above.
To verify that the custom files are loaded, in the MCP server output, you should see something like the following:
```
INFO:datacommons_mcp.app:Loaded custom instructions for server.md from gs://mybucket/instructions
INFO:datacommons_mcp.app:Loaded custom instructions for tools/get_observations.md from gs://mybucket/instructions
INFO:datacommons_mcp.app:Loaded custom instructions for tools/search_indicators.md from gs://mybucket/instructions
```
### Step 4: Connect an agent to the server
Follow any of the procedures in [Connect an AI agent to a local server](mcp.md#agent).