Skip to content

Instantly share code, notes, and snippets.

@jcstein
Created May 29, 2025 09:42
Show Gist options
  • Save jcstein/6407ed9bc1368416eab2660866f460dd to your computer and use it in GitHub Desktop.
Save jcstein/6407ed9bc1368416eab2660866f460dd to your computer and use it in GitHub Desktop.
light node v0.22.2-mocha
version: "3.8"
services:
celestia-node:
image: ghcr.io/celestiaorg/celestia-node:v0.22.2-mocha
container_name: celestia-node
entrypoint: ["/bin/sh", "-c"]
command: >
'if [ ! -d "/home/celestia/.celestia-light-mocha-4" ]; then
echo "Running init...";
celestia light init --p2p.network mocha;
fi;
echo "Starting light node...";
celestia light start
--core.ip rpc-mocha.pops.one
--core.port 9090
--p2p.network mocha
--rpc.skip-auth
--rpc.addr 0.0.0.0'
volumes:
- celestia-data:/home/celestia
networks:
- celestia-network
ports:
- "26658:26658"
restart: unless-stopped
volumes:
celestia-data:
driver: local
networks:
celestia-network:
driver: bridge
@jcstein
Copy link
Author

jcstein commented May 29, 2025

with a similar compose..results in bridge init?

version: "3.8"

services:
  celestia-node-init:
    image: ghcr.io/celestiaorg/celestia-node:v0.22.2-mocha
    container_name: celestia-node-init
    command: [
      "celestia",
      "light",
      "init",
      "--p2p.network",
      "mocha"
    ]
    volumes:
      - celestia-node-data:/home/celestia
    networks:
      - celestia-node-network
    restart: "no"

  celestia-node:
    image: ghcr.io/celestiaorg/celestia-node:v0.22.2-mocha
    container_name: celestia-node
    command: [ 
      "celestia", 
      "light", 
      "start", 
      "--core.ip", "rpc-mocha.pops.one", 
      "--core.port", "9090", 
      "--p2p.network", "mocha", 
      "--rpc.skip-auth", 
      "--rpc.addr", "0.0.0.0"
    ]
    volumes:
      - celestia-node-data:/home/celestia
    networks:
      - celestia-node-network
    restart: unless-stopped
    depends_on:
      celestia-node-init:
        condition: service_completed_successfully

volumes:
  celestia-node-data:
    driver: local
    name: celestia-node-data

networks:
  celestia-node-network:
    driver: bridge
    name: celestia-node-network
Screenshot 2025-05-29 at 18 53 07 Screenshot 2025-05-29 at 18 53 04

@jcstein
Copy link
Author

jcstein commented May 29, 2025

while this works, i notice it also still does the bridge init command on both the init and start cmd

services:
  celestia-node-init:
    image: ghcr.io/celestiaorg/celestia-node:v0.22.2-mocha
    container_name: celestia-node-init
    command: [
      "celestia",
      "light",
      "init",
      "--p2p.network", "mocha",
      "--node.store", "/home/celestia/.celestia-light-mocha-4"
    ]
    volumes:
      - ./celestia-data:/home/celestia
    networks:
      - celestia-network
    restart: "no"

  celestia-node:
    image: ghcr.io/celestiaorg/celestia-node:v0.22.2-mocha
    container_name: celestia-node
    command: [
      "celestia",
      "light",
      "start",
      "--core.ip", "rpc-mocha.pops.one",
      "--core.port", "9090",
      "--p2p.network", "mocha",
      "--rpc.skip-auth",
      "--rpc.addr", "0.0.0.0",
      "--node.store", "/home/celestia/.celestia-light-mocha-4"
    ]
    volumes:
      - ./celestia-data:/home/celestia
    networks:
      - celestia-network
    restart: unless-stopped
    depends_on:
      celestia-node-init:
        condition: service_completed_successfully
    ports:
      - "26658:26658"

networks:
  celestia-network:
    driver: bridge

@jcstein
Copy link
Author

jcstein commented May 29, 2025

@jcstein
Copy link
Author

jcstein commented May 29, 2025

new version that works:

services:
  celestia-node:
    image: ghcr.io/celestiaorg/celestia-node:v0.22.2-mocha
    container_name: celestia-node
    entrypoint: [ "/bin/sh", "-c" ]
    command: >
      'echo "Checking initialization...";
       if [ ! -d "/home/celestia/.celestia-light-mocha-4" ]; then
         echo "Running init...";
         celestia light init --p2p.network mocha;
         echo "Init completed. Checking files...";
         ls -la /home/celestia/
         find /home/celestia -name "*.toml" -type f
       else
         echo "Node already initialized";
       fi;

       echo "Starting light node...";

      if [ -f "/home/celestia/config.toml" ]; then
        echo "Config file found at: /home/celestia/config.toml"
        # Create backup file
        cp "/home/celestia/config.toml" "/home/celestia/config.toml.bak"
        
        # Update SampleFrom value with specific block height
        sed -i "s/SampleFrom = .*/SampleFrom = 5941475/" "/home/celestia/config.toml"
        
        # Update TrustedHash value
        sed -i "s/TrustedHash = .*/TrustedHash = \"944D97AC2BAEB8A7785D3848A2878091BAA68E54E3E022ABFC13B2180C2D9F91\"/" "/home/celestia/config.toml"
        
        echo "Config.toml updated:"
        echo "SampleFrom updated to: 5941475"
        echo "TrustedHash updated to: 944D97AC2BAEB8A7785D3848A2878091BAA68E54E3E022ABFC13B2180C2D9F91"
      else
        echo "Config.toml file not found at: /home/celestia/config.toml"
        echo "Available files in /home/celestia/:"
        ls -la /home/celestia/
        echo "Searching for config files:"
        find /home/celestia -name "*.toml" -type f 2>/dev/null || echo "No .toml files found"
        sleep 30
        exit 1
      fi; celestia light start --core.ip rpc-mocha.pops.one --core.port 9090 --p2p.network mocha --rpc.skip-auth --rpc.addr 0.0.0.0'
    volumes:
      - celestia-data:/home/celestia
    networks:
      - celestia-network
    ports:
      - "26658:26658"
    restart: unless-stopped

from non-working version:

services:
  celestia-node:
    image: ghcr.io/celestiaorg/celestia-node:v0.22.2
    container_name: celestia-node
    command: [ 
      "celestia", 
      "light", 
      "start", 
      "--core.ip", 
      "consensus-full-mocha-4.celestia-mocha.com", 
      "--core.port", 
      "9090", 
      "--p2p.network", 
      "mocha", 
      "--rpc.skip-auth", 
      "--rpc.addr", "0.0.0.0" 
    ]
    volumes:
      - celestia-node-data:/home/celestia
    restart: unless-stopped
    depends_on:
      celestia-node-init:
        condition: service_started 

  celestia-node-init:
    image: ghcr.io/celestiaorg/celestia-node:v0.22.2
    container_name: celestia-node-init
    volumes:
      - celestia-node-data:/home/celestia
    command: [
      "celestia",
      "light",
      "init",
      "--p2p.network",
      "mocha"
    ]

volumes:
  celestia-node-data:
    driver: local
    name: celestia-node-data

networks:
  celestia-node-network:
    driver: bridge
    name: celestia-node-network

@jcstein
Copy link
Author

jcstein commented May 29, 2025

🧠 AI Summary: Why the Original Docker Compose Setup Failed and How the Fixed Version Works

The original multi-container setup split celestia light init and celestia light start into separate services, relying on a shared volume and depends_on. This caused unreliable behavior because:

  • docker-compose doesn’t guarantee that the init container fully completes and flushes data before the start container begins.
  • If the start container runs without a valid light node store, the celestia CLI silently defaults to bridge init, writing bridge configs and keys to /home/celestia.
  • This results in a polluted volume with both bridge and light state, causing confusion and potential crashes.

✅ The fixed version runs everything in a single container with a shell-script entrypoint, which:

  • Checks for .celestia-light-mocha-4 and only runs init if needed
  • Performs safety checks on config files
  • Patches config.toml before starting the node
  • Prevents bridge init fallback by explicitly controlling the CLI flow

It also uses the correct Mocha-specific image (v0.22.2-mocha) and production RPC (rpc-mocha.pops.one), which avoids connection and sync issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment