Skip to content

Instantly share code, notes, and snippets.

@gsaslis
Last active March 28, 2024 11:30
Show Gist options
  • Select an option

  • Save gsaslis/dbd6b059afe8147cbdb12a8a89345e14 to your computer and use it in GitHub Desktop.

Select an option

Save gsaslis/dbd6b059afe8147cbdb12a8a89345e14 to your computer and use it in GitHub Desktop.

Revisions

  1. gsaslis renamed this gist May 23, 2023. 1 changed file with 0 additions and 0 deletions.
  2. gsaslis revised this gist May 23, 2023. 1 changed file with 71 additions and 0 deletions.
    71 changes: 71 additions & 0 deletions docker-compose.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    version: "3.7"
    services:
    radicle-node:
    image: gcr.io/radicle-services/radicle-node:${RADICLE_IMAGE_TAG:-latest}
    command: ${RADICLE_NODE_OPTIONS}
    build:
    dockerfile: ./radicle-node/Dockerfile
    context: .
    environment:
    RUST_LOG: debug
    RAD_PASSPHRASE: ${RAD_PASSPHRASE:-seed}
    RUST_BACKTRACE: 1
    GIT_TRACE: 1
    GIT_TRACE_PACKET: 1
    volumes:
    - ${RAD_ROOT:-/mnt/radicle/heartwood}:/root/
    init: true
    restart: unless-stopped
    networks:
    - radicle-services
    deploy:
    resources:
    limits:
    memory: 6gb
    ports:
    - ${RADICLE_NODE_PORT:-8776}:8776
    radicle-httpd:
    image: gcr.io/radicle-services/radicle-httpd:${RADICLE_IMAGE_TAG:-latest}
    build:
    dockerfile: ./radicle-httpd/Dockerfile
    context: .
    environment:
    RUST_LOG: debug
    RUST_BACKTRACE: 1
    volumes:
    - ${RAD_ROOT:-/mnt/radicle/heartwood}:/root/
    init: true
    restart: unless-stopped
    networks:
    - radicle-services
    deploy:
    resources:
    limits:
    memory: 6gb
    ports:
    - ${RADICLE_API_PORT:-8886}:8080
    caddy:
    image: caddy:2.4.5
    entrypoint:
    - sh
    - -euc
    - |
    cat <<EOF >/etc/caddy/Caddyfile
    $RADICLE_DOMAIN {
    reverse_proxy radicle-httpd:8080
    }
    EOF
    caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
    ports:
    - 80:80
    - 443:443
    environment:
    RADICLE_DOMAIN: $RADICLE_DOMAIN
    container_name: caddy
    restart: unless-stopped
    networks:
    - radicle-services

    networks:
    radicle-services:
    name: radicle-services
  3. gsaslis renamed this gist Apr 6, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. gsaslis renamed this gist Apr 6, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. gsaslis created this gist Apr 6, 2023.
    90 changes: 90 additions & 0 deletions README.asciidoc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,90 @@
    # Running in Containers
    In case you want to run radicle in containers, on the same host (e.g. your laptop),
    you can use the `docker-compose.yml` file provided within this repo.

    ## 1. Create a profile

    1. Create a folder where you will store the data of your node. e.g. `mkdir -p ~/radicle/profiles/bob/.radicle`
    1. Set `RAD_HOME` : `export RAD_HOME=~/radicle/profiles/bob/.radicle`
    1. Create a key:
    - Pick a good passphrase and store it in your password manager
    - go ahead with creating the key `rad auth --stdin` (or use `RAD_PASSPHRASE` env var)
    - your profile should be created in `~/radicle/profiles/bob/.radicle`.
    ## 2. Build the container images

    This takes a couple of minutes - depending on your machine - as it needs
    to download the parent container images, and also all the rust
    dependencies and then compile the code:

    ```bash
    docker-compose build
    ```


    ## 3. Choose scenario

    Choose your scenario:

    * [Run a Radicle node on my machine, using docker](#run-a-single-radicle-node)
    * [Run multiple Radicle nodes on my machine, to try things out / learn how Radicle works.](#run-multiple-radicle-nodes-locally)
    ### 3A. Run a single Radicle node

    This is as simple as using the existing `docker-compose.yml` and simply passing in
    the path to the **parent** folder of `RAD_HOME`, where you previously created the
    profile.

    ```bash
    RAD_ROOT=~/radicle/profiles/bob docker-compose up radicle-node radicle-httpd
    ```

    ### 3B. Run Multiple Radicle Nodes Locally

    You would probably use this setup if you want to play around with multiple nodes and
    study, understand and learn how Radicle works and how projects (and their data) are
    replicated across nodes. **This setup is not recommended for production use!**

    The setup is slightly different between the first node you run and the additional ones.

    #### Run First Node

    For the first node you want to start on your machine, you can:

    1. Create a `.env.$nodename` file that will store all your environment variables:
    ```yaml
    # these options are especially useful in a development setting - probably not for production use
    RADICLE_NODE_OPTIONS=--tracking-policy track --tracking-scope all
    # Note the difference between RAD_ROOT vs. RAD_HOME.
    RAD_ROOT=~/radicle/profiles/bob
    # ensure these ports are free on your machine
    RADICLE_API_PORT=8888
    RADICLE_NODE_PORT=8778
    ```
    1. Start the containers:
    ```bash
    # we don't need to start the included `caddy` service
    docker-compose --env-file=.env.bob --project-name=bob up radicle-node radicle-httpd
    ```
    #### Run additional nodes in your network

    For each additional node:
    1. Create a new profile in a new directory, using the steps in the "Create a profile" section above.
    1. Create a `.env.$nodename` file that will store all your environment variables:
    ```dotenv
    # IMPORTANT: substitute `<FIRST_NODE_ID>` with the node id of your **first** node ( `RAD_HOME=<path_to_first_node_profile> rad self | grep "Node ID"` ).
    # IMPORTANT: substitute `<FIRST_NODE_PROJECT_NAME>` with the `--project-name` value you used in your first node. In our example, this would be `bob`.
    RADICLE_NODE_OPTIONS=--tracking-policy track --tracking-scope all --connect <FIRST_NODE_ID>@<FIRST_NODE_PROJECT_NAME>_radicle-node_1.radicle-services:8776
    # Use the new profile directory
    RAD_ROOT=~/radicle/profiles/alice
    # pick a new set of ports that are free on your machine
    RADICLE_API_PORT=8887
    RADICLE_NODE_PORT=8777
    ```
    1. Start the containers:
    ```bash
    # we don't need to start the included `caddy` service
    docker-compose --env-file=.env.alice --project-name=alice up radicle-node radicle-httpd
    ```
    1. The 2 nodes should now connect to each other ! You should be able to see a "Connected to <node id>" message and after a couple of minutes some Ping messages (and Pong responses) being exchanged. 🚀