Deploy your Blockchain with Ignite Spaceship
Ignite Spaceship is tool that helps you deploy your blockchain with SSH.
It extends the Ignite CLI functionality, making it easier to set up and manage your Cosmos SDK blockchain on remote servers.
Prerequisites
Before we begin, make sure you have the following:
- Ignite CLI: Version
v28.4.0
or higher - A blockchain scaffolded using Ignite
- SSH access to a remote server
Introduction
You've written your Cosmos SDK blockchain with Ignite scaffolding, created your own modules, and now it's time to deploy the blockchain permanently. Spaceship adopts the settings of your current config.yml
file, making the deployment process seamless.
Getting Started
-
Navigate to your blockchain's directory:
cd example
TIP: If you don't have a blockchain project, create one with
ignite scaffold chain example
-
Ensure your
config.yml
file is properly set up with your desired chain configuration.
Deployment Options
Spaceship provides multiple ways to connect to your SSH server for deployment. Choose the method that best suits your setup:
-
Using a private key:
ignite spaceship deploy root@127.0.0.1 --key $HOME/.ssh/id_rsa
-
Specifying user and key separately:
ignite spaceship deploy 127.0.0.1 --user root --key $HOME/.ssh/id_rsa
-
Using a password:
ignite spaceship deploy 127.0.0.1 --user root --password password
-
Using a private key with a passphrase:
ignite spaceship deploy root@127.0.0.1 --key $HOME/.ssh/id_rsa --key-password key_password
What Happens During Deployment
When you run the deploy command, Spaceship performs the following actions:
- Builds the blockchain binary
- Sets up the chain's home directory based on your configuration
- Connects to the specified SSH server
- Establishes workspaces on the remote server
- Transfers the binary
- Executes the binary using a runner script
Workspace Structure
Spaceship organizes the deployment in the following structure on the remote server:
$HOME/workspace/<chain-id>/
├── bin/ # Contains the chain binary
├── home/ # Stores chain data
├── log/ # Holds logs of the running chain
├── run.sh # Script to start the binary in the background
└── spaceship.pid # Stores the PID of the running chain instance
Managing Your Deployed Chain
After deployment, you can manage your blockchain using the following commands:
-
Check status:
ignite spaceship status root@127.0.0.1 --key $HOME/.ssh/id_rsa
-
View logs:
ignite spaceship log root@127.0.0.1 --key $HOME/.ssh/id_rsa
-
Watch logs in real-time:
ignite spaceship log root@127.0.0.1 --key $HOME/.ssh/id_rsa --real-time
-
Restart the chain:
ignite spaceship restart root@127.0.0.1 --key $HOME/.ssh/id_rsa
-
Stop the chain:
ignite spaceship stop root@127.0.0.1 --key $HOME/.ssh/id_rsa
Redeploying
To redeploy the chain on the same server without overwriting the home directory, use the --init-chain
flag:
ignite spaceship deploy root@127.0.0.1 --key $HOME/.ssh/id_rsa --init-chain
This will reinitialize the chain if necessary.
Configuring Your Chain
You can override the default chain configuration by modifying the Ignite configuration file. Here's an example of how to customize your config.yml
:
validators:
- name: alice
bonded: '100000000stake'
app:
pruning: "nothing"
config:
moniker: "mychain"
client:
output: "json"
Spaceship initializes the chain locally in a temporary folder using this config file and then copies the configuration to the remote machine at $HOME/workspace/<chain-id>/home
.
Best Practices
- Always ensure your SSH key or password is secure. Best practice is to use keys instead of passwords.
- Regularly check the status and logs of your deployed chain.
- Keep your Ignite CLI and Spaceship up to date for the latest features and security improvements.
- Backup your chain data regularly.
Troubleshooting
If you encounter issues during deployment or management:
- Check your SSH connection and credentials.
- Verify that the remote server meets all prerequisites.
- Review the logs for any error messages.
- Ensure your
config.yml
is correctly formatted and contains valid settings.
You should now be able to deploy and manage your Cosmos SDK blockchain using Ignite Spaceship. Happy deploying!