Spark: Local Node Setup w/Docker

Spark: Local Node Setup w/Docker https://celo.academy/uploads/default/optimized/2X/6/65db9fcf3701199cea8c449db3211ff0f28b37a5_2_1024x576.png
none 0.0 0

In this tutorial, we will walk through the process of setting up a local node on Celo using Docker. By following these steps, you will be able to run a Celo node on your computer. Let’s get started!

Prerequisites

Before you begin, make sure you have Docker installed on your computer. Docker allows you to create and manage containers, which will be used to run the Celo node.

Step 1: Create a New Folder

Open a new terminal and create a new folder to contain your Docker container. Navigate into the folder using the terminal.

bashCopy code

mkdir celo-node
cd celo-node

Step 2: Pull the Celo Alpha Horse Node Image

Export a variable with the Celo Alpha Horse node image and pull it using Docker.

bashCopy code

export CELO_IMAGE=us.gcr.io/celo-org/celo-node:alpha-horse
docker pull $CELO_IMAGE

Step 3: Run the Celo Node Image

Now, let’s run the Celo node image with the following parameters:

bashCopy code

docker run -it --restart always --stop-timeout 300 --name celo-node -p 8545:8545 -v $PWD:/root/celo -e CELO_IMAGE=$CELO_IMAGE --entrypoint /bin/bash $CELO_IMAGE

This command runs the image in interactive mode, maps port 8545 in the container to port 8545 on your host machine, and mounts the current working directory as a volume in the container at /root/celo. This allows the node to persist data across container restarts.

Step 4: Configure the Celo Node

Inside the container, you can configure the Celo node according to your requirements. Here are some common configurations:

Sync Mode and Logging Level

Set the node to sync with the network in light mode and set the logging level to level 3 (info).

bashCopy code

celo --nodedir /root/celo init light --verbosity 3

Enable RPC Server

Enable the HTTP RPC server to listen for connections on all available network interfaces.

bashCopy code

celo --nodedir /root/celo run --networkid mainnet --rpc --rpcaddr 0.0.0.0

API Configuration

Specify which APIs to enable for the HTTP RPC server. For example, to enable all APIs:

bashCopy code

celo --nodedir /root/celo run --networkid mainnet --rpc --rpcaddr 0.0.0.0 --rpcapi eth,net,web3,debug,admin,personal,txpool

Data Directory

Set the node’s data directory to /root/celo (already configured in the Docker volume).

Insecure Unlock (for development purposes)

If you want to allow insecure unlocking of the node (for development purposes), use the following flag:

bashCopy code

celo --nodedir /root/celo run --networkid mainnet --rpc --rpcaddr 0.0.0.0 --insecure-unlock

Step 5: Verify Container Running

You should now see your new container running in the Docker UI. Switch back to the command-line interface (CLI) for the next steps.

Step 6: Create a New Account

To create a new account using your local node, run the following command inside the container:

bashCopy code

celo --nodedir /root/celo account new

Save the generated password and take note of the address of your new account.

Step 7: Access the Keystore File

If you want to access the keystore file for your new account, you can go to the Docker container files tab in the Docker UI and navigate to the appropriate path.

Step 8: Stop the Celo Node

To stop the Celo node, run the following command:

bashCopy code

docker stop celo-node

Congratulations! You have successfully set up a Celo local node on your computer using Docker. Feel free to explore further and dive into the world of Celo blockchain development. See you on the next tutorial!

3 Likes

The tutorial is easy to understand. Everything was explained clearly