This guide is for production operations on the Gitcoin Data Layer.
- Make sure you have already created the S3 bucket and ECR repository. Refer to the README.md for more information.
- Make sure you have already created environment variables and secrets in the repository settings. Refer to the README.md for more information.
-
Run
Deploy to AWS
workflow, and wait until it finishes. -
Log in to your AWS account
-
Copy your database endpoint from RDS > Databases > gitcoin-data-layer-staging-rds > Connectivity and security > Endpoint
-
Go to EC2 > Instances > gitcoin-data-layer-production-bastion > Connect > Session Manager > Connect ( IF YOU CAN’T USE
SessionManager
try rebooting the instance) -
Once in the terminal run:
-
sudo su
-
cd ~
-
git clone https://github.com/defi-wonderland/grants-stack-indexer-v2.git
-
cd grants-stack-indexer-v2
-
set env variables for scripts
-
nano ./scripts/migrations/.env
DATABASE_URL=postgres://{{DB_USER}}:{{DB_PASSWORD}}@{{DB_URL}}:5432/GitcoinDatalayerGreen DATABASE_SCHEMA=public NODE_ENV=production
-
-
chmod +x ./deployment/bastion_scripts/install_dependencies.sh
-
./deployment/bastion_scripts/install_dependencies.sh
-
source ~/.bashrc
-
pnpm i && pnpm build
-
pnpm db:create-databases
-
nano ./scripts/migrations/.env
DATABASE_URL=postgres://{{DB_USER}}:{{DB_PASSWORD}}@{{DB_URL}}:5432/GitcoinDatalayerGreen DATABASE_SCHEMA=public NODE_ENV=production
-
pnpm db:cache:migrate
-
nano ./scripts/migrations/.env
DATABASE_URL=postgres://{{DB_USER}}:{{DB_PASSWORD}}@{{DB_URL}}:5432/GitcoinDatalayerBlue DATABASE_SCHEMA=public NODE_ENV=production
-
pnpm db:cache:migrate
-
nano ./scripts/bootstrap/.env
NODE_ENV=production DATABASE_URL=postgres://{{DB_USER}}:{{DB_PASSWORD}}@{{DB_URL}}:5432/GitcoinDatalayerGreen DATABASE_SCHEMA=public INDEXER_URL={{INDEXER_URL}} PUBLIC_GATEWAY_URLS=[...{{ IPFS_PUBLIC_GATEWAYS}}] CHAIN_IDS=[10,1] LOG_LEVEL=info PRICING_SOURCE=coingecko COINGECKO_API_KEY=CG-{{YOUR_COINGECKO_API_KEY}} COINGECKO_API_TYPE=pro
-
pnpm bootstrap:metadata
-
pnpm bootstrap:pricing
-
nano ./scripts/migrations/.env
DATABASE_URL=postgres://{{DB_USER}}:{{DB_PASSWORD}}@{{DB_URL}}:5432/GitcoinDatalayerGreen DATABASE_SCHEMA=public NODE_ENV=production
-
pnpm db:migrate
-
nano ./scripts/migrations/.env
DATABASE_URL=postgres://{{DB_USER}}:{{DB_PASSWORD}}@{{DB_URL}}:5432/GitcoinDatalayerBlue DATABASE_SCHEMA=public NODE_ENV=production
-
pnpm db:migrate
-
-
nano ./scripts/hasura-config/.env
HASURA_ENDPOINT={{API_GW_URL}} HASURA_ADMIN_SECRET={{YOUR_HASURA_ADMIN_SECRET}} HASURA_SCHEMA=public
-
pnpm api:configure
-
If you made any changes to Envio indexer, you need to wait until the indexer is ready and stable.
-
Update the TERRAFORM_VARS with the new image tag, or changes. (You can run
Current Deployment State
workflow to see the current state of the deployment, and the active environment. If the deployment state issingle
, it means that there is just one deployment and is the active one. If the deployment state isdeployment
, it means that there are two deployments, the blue and the green, and the active environment isactive_deployment
.) -
Run
Deploy Blue Green (Start upgrade - Step 1)
workflow and deploy the target deployment -
Follow the instructions to set up the target deployment:
- Set migrations with target environment
nano ./scripts/migrations/.env
DATABASE_URL=postgres://{{DB_USER}}:{{DB_PASSWORD}}@{{DB_URL}}:5432/GitcoinDatalayer{{Green|Blue(Should be target environment)}} DATABASE_SCHEMA=public NODE_ENV=production
- pnpm db:reset
- pnpm db:cache:reset
- pnpm db:cache:migrate
- pnpm db:copy-cache -f {{ green | blue (should be the source environment) }}
- pnpm db:migrate
- Set hasura config
nano ./scripts/hasura-config/.env
HASURA_ENDPOINT={{PUBLIC_IP_ECS_TASK}} HASURA_ADMIN_SECRET={{YOUR_HASURA_ADMIN_SECRET}} HASURA_SCHEMA=public
- pnpm api:configure
- Set migrations with target environment
-
Wait until the new deployment is stable,you can go to the hasura api task on ECS and get the IP address of the task and check if the api is working. (You can rollback running again using
Promote Blue Green (Start upgrade - Step 2)
workflow) -
Run
Promote Blue Green (Start upgrade - Step 2)
workflow. -
Validate that is stable and working .
-
Once you are sure that the new deployment is stable, you can destroy the old deployment by running
Destroy Blue Green (Start upgrade - Step 3)
workflow.
- Wait for the new chain to be fully indexed on Envio indexer.
- Update the TERRAFORM_VARS with the new chain in
CHAINS
environment variable. - Run
Upgrade current deployment
workflow and deploy it to the current working deployment.
- Wait until envio indexer is ready and stable.
- Update TERRAFORM_VARS with the new event image tag.
- Do blue green deployment
- Wait until envio indexer is ready and stable.
- Update TERRAFORM_VARS with the new image tag.
- Do blue green deployment