Skip to content

fix: docker-compose tutorial #581

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

Merged
merged 4 commits into from
Jul 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 33 additions & 55 deletions tutorials/docker-compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,22 @@ Docker Compose version v2.23.0-desktop.1

## 🛠️ Setting up your environment {#setting-up-your-environment}

In addition to our chain, we need to run a DA and Sequencer node.
In addition to our chain, we need to run a DA.

We will use the [local-da](https://github.com/rollkit/local-da) and [local-sequencer](https://github.com/rollkit/go-sequencing) for this tutorial and run it with our chain.
We will use the [local-da](https://github.com/rollkit/local-da) for this tutorial and run it with our chain.

To save time, we can use their respective Dockerfiles:

* [local-da Dockerfile](https://github.com/rollkit/local-da/blob/main/Dockerfile)
* [local-sequencer Dockerfile](https://github.com/rollkit/go-sequencing/blob/main/Dockerfile)
To save time, we can use the local-da Dockerfile:

* [local-da Dockerfile](https://github.com/rollkit/rollkit/blob/main/Dockerfile.da)
This will allow us to focus on how we can run the gm-world chain with Docker Compose.

### 🐳 Dockerfile {#dockerfile}

First, we need to create a Dockerfile for our gm-world chain. Create a new file called `Dockerfile` in the root of the `gm` directory and add the following code:
First, we need to create a Dockerfile for our gm-world chain. Create a new file called `Dockerfile.gm` in the root of the `gm` directory and add the following code:

```dockerfile-vue
# Stage 1: Install ignite CLI and rollkit
FROM golang as base
FROM golang AS base

# Install dependencies
RUN apt update && \
Expand All @@ -63,11 +61,11 @@ RUN apt update && \
ca-certificates \
curl

RUN curl -sSL https://rollkit.dev/install.sh | bash
# Install rollkit
RUN curl -sSL https://rollkit.dev/install.sh | sh -s {{constants.rollkitLatestTag}}

# Install ignite
RUN curl https://get.ignite.com/cli@{{constants.igniteVersionTag}}! | bash
RUN curl https://get.ignite.com/cli! | bash

# Set the working directory
WORKDIR /app
Expand All @@ -80,17 +78,10 @@ RUN go mod download
# Copy all files from the current directory to the container
COPY . .

# Remove the rollkit.toml and entrypoint files if they exist. This is to avoid cross OS issues.
RUN rm entrypoint rollkit.toml

# Build the chain
RUN ignite chain build && ignite rollkit init

# Initialize the rollkit.toml file
RUN rollkit toml init

# Run rollkit command to initialize the entrypoint executable
RUN rollkit
RUN ignite app install -g github.com/ignite/apps/rollkit
RUN ignite chain build -y
RUN ignite rollkit init

# Stage 2: Set up the runtime environment
FROM debian:bookworm-slim
Expand All @@ -104,33 +95,32 @@ RUN apt update && \
WORKDIR /root

# Copy over the rollkit binary from the build stage
COPY --from=base /go/bin/rollkit /usr/bin
COPY --from=base /go/bin/gmd /usr/bin

# Copy the entrypoint and rollkit.toml files from the build stage
COPY --from=base /app/entrypoint ./entrypoint
COPY --from=base /app/rollkit.toml ./rollkit.toml

# Copy the $HOME/.gm directory from the build stage.
# This directory contains all your chain config.
COPY --from=base /root/.gm /root/.gm

# Ensure the entrypoint script is executable
RUN chmod +x ./entrypoint

# Keep the container running after it has been started
# CMD tail -f /dev/null

ENTRYPOINT [ "rollkit" ]
CMD [ "start", "--rollkit.aggregator", "--rollkit.sequencer_rollup_id", "gmd"]

ENTRYPOINT ["gmd"]
CMD ["start","--rollkit.node.aggregator"]
```

This Dockerfile sets up the environment to build the chain and run the gm-world node. It then sets up the runtime environment to run the chain. This allows you as the developer to modify any files, and then simply rebuild the Docker image to run the new chain.

Build the docker image by running the following command:

```bash
docker build -t gm-world .
docker build -t gm-world -f Dockerfile.gm .
```

```bash
cd rollkit
docker build -t local-da -f Dockerfile.da .
cd ..
```

You can then see the built image by running:
Expand Down Expand Up @@ -166,42 +156,24 @@ services:
command:
[
"start",
"--rollkit.aggregator",
"--rollkit.node.aggregator",
"--rollkit.da.address",
"http://0.0.0.0:7980",
"--rollkit.sequencer_address",
"0.0.0.0:50051",
"--rollkit.sequencer_rollup_id",
"gm",
]
# Ensures the local-da service is up and running before starting the chain
depends_on:
- local-da
- local-sequencer

# Define the local DA service
local-da:
# Use the published image from rollkit
image:
ghcr.io/rollkit/local-da:{{constants.localDALatestTag}}
image: local-da
# Set the name of the docker container for ease of use
container_name: local-da
# Publish the ports to connect
ports:
- "7980:7980"

# Define the local sequencer service
local-sequencer:
# Use the published image from rollkit
image:
ghcr.io/rollkit/go-sequencing:{{constants.goSequencingLatestTag}}
# Set the name of the docker container for ease of use
container_name: local-sequencer
# Start the sequencer with the listen all flag and the rollup id set to gm
command: ["-listen-all", "-rollup-id=gm"]
# Publish the ports to connect
ports:
- "50051:50051"
```

We now have all we need to run the gm-world chain and connect to a local DA node.
Expand Down Expand Up @@ -231,10 +203,9 @@ docker ps
You should see output like the following:

```bash
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
86f9bfa5b6d2 gm-world "rollkit start --rol…" 7 minutes ago Up 3 seconds gm-world
67a2c3058e01 local-sequencer "local-sequencer -li…" 11 minutes ago Up 3 seconds 0.0.0.0:50051->50051/tcp local-sequencer
dae3359665f8 local-da "local-da -listen-all" 2 hours ago Up 3 seconds 0.0.0.0:7980->7980/tcp local-da
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d50c7f2fffde local-da "local-da -listen-all" 10 seconds ago Up 9 seconds 0.0.0.0:7980->7980/tcp local-da
b9d5e80e81fb gm-world "gmd start --rollkit…" 27 minutes ago Up 9 seconds gm-world
```

We can see the gm-world chain running in container `gm-world` and the local DA network running in container `local-da`.
Expand All @@ -255,6 +226,13 @@ exit

Then you can shut down your chain environment by running `CRTL+C` in your terminal.


If you want to stop the docker containers without shutting down your terminal, you can run:

```bash
docker compose down
```

## 🎉 Next steps

Congratulations again! You now know how to run your chain with docker compose and interact with it using the Rollkit CLI in the docker container.