Advanced Usage

Multi-Environment Deployments

Configure and automate deployments across Devnet, Testnet, and Mainnet with environment-specific settings, versioning, rollbacks, and secret management via codi.toml.

Configure and automate deployments across Devnet, Testnet, and Mainnet with environment-specific settings, versioning, rollbacks, and secret management via codi.toml.

Written By: Harry Osborn

Last Updated on June 5, 2025

Introduction

Managing multiple clusters is critical for safe on-chain development. This page covers how to define environments, override configurations, automate versioning with codified deploy matrices, and roll back on failure—all within CODI’s platform.


1. Environment Concepts

  • Clusters: Devnet for experiments, Testnet for staging, Mainnet for production.

  • Isolation: Separate state, tokens, and endpoints per environment to prevent cross-contamination.


2. Configuring codi.toml for Clusters

[deploy.devnet]
network = "devnet"
programPath = "programs/my-app"
[deploy.testnet]
network = "testnet"
timeoutSeconds = 600
[deploy.mainnet]

  • Sections: Use environment keys under [deploy].

  • Overrides: Specify network, retries, timeouts per cluster.


3. Automated Versioning & Rollbacks

  • Semantic Version Tags: CODI auto-increments version based on Git tags or manual --version flag.

  • Snapshot Nodes: MCP stores last successful deploy under mcp.deploy.<env> for each cluster.

  • Rollback Command:

    Reverts to the last snapshot for that environment.


4. Environment-Specific Overrides & Secrets

  • Secret Store: Safely reference environment variables (SOLANA_WALLET_KEY_DEV, SOLANA_WALLET_KEY_MAIN) in CI or UI.

  • Overrides: Use codi config set to change per-environment parameters:


5. Example: Deploy Matrix

Job

Devnet

Testnet

Mainnet

Command

codi deploy --network devnet

codi deploy --network testnet

codi deploy --network mainnet

Timeout

300s

600s

900s

Retries

2

3

5

RollbackKey

mcp.deploy.devnet

mcp.deploy.testnet

mcp.deploy.mainnet


Conclusion

Multi-environment deployments in CODI provide safety, traceability, and flexibility. Define clusters in codi.toml, automate versioning and rollbacks, and manage secrets per environment to streamline your on-chain release process.


© 2025 CODI all rights reserved | Created with ♥️

© 2025 CODI all rights reserved | Created with ♥️

© 2025 CODI all rights reserved | Created with ♥️