Deploy your Blockchain with Ignite Spaceship

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

  1. Navigate to your blockchain's directory:

    cd example
    

    TIP: If you don't have a blockchain project, create one with ignite scaffold chain example

  2. 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:

  1. Using a private key:

    ignite spaceship deploy root@127.0.0.1 --key $HOME/.ssh/id_rsa
    
  2. Specifying user and key separately:

    ignite spaceship deploy 127.0.0.1 --user root --key $HOME/.ssh/id_rsa
    
  3. Using a password:

    ignite spaceship deploy 127.0.0.1 --user root --password password
    
  4. 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:

  1. Builds the blockchain binary
  2. Sets up the chain's home directory based on your configuration
  3. Connects to the specified SSH server
  4. Establishes workspaces on the remote server
  5. Transfers the binary
  6. 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:

  1. Check status:

    ignite spaceship status root@127.0.0.1 --key $HOME/.ssh/id_rsa
    
  2. View logs:

    ignite spaceship log root@127.0.0.1 --key $HOME/.ssh/id_rsa
    
  3. Watch logs in real-time:

    ignite spaceship log root@127.0.0.1 --key $HOME/.ssh/id_rsa --real-time
    
  4. Restart the chain:

    ignite spaceship restart root@127.0.0.1 --key $HOME/.ssh/id_rsa
    
  5. 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

  1. Always ensure your SSH key or password is secure. Best practice is to use keys instead of passwords.
  2. Regularly check the status and logs of your deployed chain.
  3. Keep your Ignite CLI and Spaceship up to date for the latest features and security improvements.
  4. Backup your chain data regularly.

Troubleshooting

If you encounter issues during deployment or management:

  1. Check your SSH connection and credentials.
  2. Verify that the remote server meets all prerequisites.
  3. Review the logs for any error messages.
  4. 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!