Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: Create a single Dockerfile that works for full and light celestia-nodes #295

Merged
merged 13 commits into from
Dec 24, 2021

Conversation

jbowen93
Copy link
Contributor

@jbowen93 jbowen93 commented Dec 16, 2021

Create a new Dockerfile that works for both celestia-node full and light nodes while matching the expectations of both the docker-compose and k8s cluster setups.

At runtime the a NODE_TYPE environment variable matching either full or light is expected.

If not provided it defaults to full.

For examples see the docker-compose config and the k8s config.

This has been manually tested by building the Docker image

docker build -f docker/Dockerfile -t jbowen93/celestia-node:multi

and then testing it with docker-compose

cd devnet
./start-docker.sh

and with kubernetes

cd devnet
kubectl create -f k8s/core-nodes -R && \
sleep 45s && \
kubectl create -f k8s/light-nodes -R

docker/Dockerfile Show resolved Hide resolved
docker/Dockerfile Outdated Show resolved Hide resolved
Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this @jbowen93

Can you change the name of the dockerfile to bridge.Dockerfile since this will be called a bridge node? Similarly after merging #294, the NODETYPE will have to be bridge.

@jbowen93
Copy link
Contributor Author

Thank you so much for this @jbowen93

Can you change the name of the dockerfile to bridge.Dockerfile since this will be called a bridge node? Similarly after merging #294, the NODETYPE will have to be bridge.

I don't believe we should change the name of the Dockerfile. This Dockerfile is intentionally designed to work with both full nodes (now bridge nodes) and light nodes, you just pass different environment variables and startup commands. See an example of a full/bridge node and a light node.

Also keep in mind that the env vars set in the Dockerfile are only defaults that should be overwritten later. From the docs:

When you set the same environment variable in multiple files, here’s the priority used by Compose to choose which value to use:

Compose file
Shell environment variables
Environment file
Dockerfile
Variable is not defined

@jbowen93
Copy link
Contributor Author

Lint should be resolved after #308 is merged

@renaynay
Copy link
Member

I don't believe we should change the name of the Dockerfile. This Dockerfile is intentionally designed to work with both full nodes (now bridge nodes) and light nodes, you just pass different environment variables and startup commands. See an example of a full/bridge node and a light node.

@jbowen93 Okay as long as eventually we have automation for pushing three different images to dockerhub on release, one for bridge, full, and light so that people can just pull and run.

@renaynay renaynay changed the title Create a single Dockerfile that works for full and light celestia-nodes docker: Create a single Dockerfile that works for full and light celestia-nodes Dec 24, 2021
@renaynay renaynay merged commit 5515d68 into celestiaorg:main Dec 24, 2021
@jbowen93
Copy link
Contributor Author

I don't believe we should change the name of the Dockerfile. This Dockerfile is intentionally designed to work with both full nodes (now bridge nodes) and light nodes, you just pass different environment variables and startup commands. See an example of a full/bridge node and a light node.

@jbowen93 Okay as long as eventually we have automation for pushing three different images to dockerhub on release, one for bridge, full, and light so that people can just pull and run.

Just clarifying some more. This image supports multiple node types at run time. There is no need to push different images.

Full node (will rename to bridge)

 docker run --network docker_localnet -e NODE_TYPE=full \
 jbowen93/celestia-node:multi celestia full --repo.path /celestia-full start \
 --core.remote tcp://192.167.10.2:26657 \
 --headers.trusted-hash "64D831D041A57A9D93078B445F7B1347024A9B5A8A444086C0B556B65A8A96C7" \
 --p2p.mutual "/ip4/192.167.10.7/tcp/2121/p2p/12D3KooWGGtejCnY3Q9XUUy6muSRm1Whgf8ijTRtwJ8DGA1164EB,/ip4/192.167.10.8/tcp/2121/p2p/12D3KooWQCbe8R4QD1jxnUs5SWWdFg5Kza3mBE94Cz1RJnLTXfNM,/ip4/192.167.10.9/tcp/2121/p2p/12D3KooWA6uovjYCgFvWhAbrcQmnLihFy1gZkdyJt8SrPKZjeWda"

light node

docker run --network docker_localnet -e NODE_TYPE=light \
jbowen93/celestia-node:multi celestia light --repo.path /celestia-light \
start --headers.trusted-peer "/ip4/192.167.0.2/tcp/2121/p2p/12D3KooWHLnz72q5mmCBooVbkjNcSWTzhEsc6gtSPwCqgervgNnb" \
 --headers.trusted-hash "64D831D041A57A9D93078B445F7B1347024A9B5A8A444086C0B556B65A8A96C7"

I did a quick manual test for this:

  1. Set up the core nodes with docker-compose docker/core-docker-compose.yml up
  2. Run the above full node docker run command
  3. Retrieve the ip address of the full node by looking through docker network inspect docker_localnet
  4. Get the peer id for the full node. I ran docker logs a345973ca120 2> /dev/null for this
  5. Run the above light node docker run command

Bidon15 added a commit to Bidon15/celestia-node that referenced this pull request Jan 11, 2022
…estia-node`s (celestiaorg#295)

* Working Dockerfile

* update changelog

* .github/workflows/lint: always use latest version of linter

* Add comment to Dockerfile linking to issue requiring SLEEP

Co-authored-by: Nguyen Nhu Viet <braveryandglory@gmail.com>

* changelog: add entry for celestiaorg#308

* Update .github/workflows/lint.yml

Co-authored-by: Nguyen Nhu Viet <braveryandglory@gmail.com>

* Working Dockerfile

* update changelog

* Add comment to Dockerfile linking to issue requiring SLEEP

Co-authored-by: Nguyen Nhu Viet <braveryandglory@gmail.com>

* Remove sleep from Dockerfile and entrypoint.sh

Co-authored-by: Wondertan <hlibwondertan@gmail.com>
Co-authored-by: Nguyen Nhu Viet <braveryandglory@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

docker: Create CI pipeline to build docker image and push on every release to dockerhub
5 participants