-
Notifications
You must be signed in to change notification settings - Fork 188
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
feat: docker && docker-compose #2906
Conversation
WalkthroughOhayo, sensei! This pull request introduces a comprehensive Docker setup for the Dojo game engine, including a multi-stage Dockerfile, a Docker Compose configuration, an image build script, and a detailed Torii configuration file. The changes aim to simplify deployment and provide a standardized containerized environment for running Dojo services like Katana and Torii. Changes
Assessment against linked issues
The changes fully address the requirements outlined in issue #2902, providing a complete Docker and Docker Compose setup for Dojo engine services. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
docker/Dockerfile
(1 hunks)docker/docker-compose.yml
(1 hunks)docker/image_build.sh
(1 hunks)docker/torii.toml
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- docker/torii.toml
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: clippy
# Build the Docker image | ||
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling and build context path, sensei!
The build command needs error handling and explicit build context.
-docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
+if ! docker build -t ${IMAGE_NAME}:${IMAGE_TAG} -f docker/Dockerfile .; then
+ echo "Failed to build image"
+ exit 1
+fi
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# Build the Docker image | |
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} . | |
# Build the Docker image | |
if ! docker build -t ${IMAGE_NAME}:${IMAGE_TAG} -f docker/Dockerfile .; then | |
echo "Failed to build image" | |
exit 1 | |
fi |
# Log in to Docker Hub | ||
docker login --username ${DOCKERHUB_USERNAME} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Secure the Docker Hub authentication, sensei!
Consider using Docker config or environment variables for secure credential handling.
-docker login --username ${DOCKERHUB_USERNAME}
+if [ -z "${DOCKERHUB_TOKEN}" ]; then
+ echo "DOCKERHUB_TOKEN is required"
+ exit 1
+fi
+echo "${DOCKERHUB_TOKEN}" | docker login --username "${DOCKERHUB_USERNAME}" --password-stdin
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# Log in to Docker Hub | |
docker login --username ${DOCKERHUB_USERNAME} | |
# Log in to Docker Hub | |
if [ -z "${DOCKERHUB_TOKEN}" ]; then | |
echo "DOCKERHUB_TOKEN is required" | |
exit 1 | |
fi | |
echo "${DOCKERHUB_TOKEN}" | docker login --username "${DOCKERHUB_USERNAME}" --password-stdin |
IMAGE_NAME="dojoengine" | ||
IMAGE_TAG="latest" | ||
DOCKERHUB_USERNAME="your_dockerhub_username" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Ohayo! Let's make the image configuration more flexible, sensei!
Consider using environment variables instead of hardcoded values:
-IMAGE_NAME="dojoengine"
-IMAGE_TAG="latest"
-DOCKERHUB_USERNAME="your_dockerhub_username"
+IMAGE_NAME="${DOCKER_IMAGE_NAME:-dojoengine}"
+IMAGE_TAG="${DOCKER_IMAGE_TAG:-latest}"
+DOCKERHUB_USERNAME="${DOCKERHUB_USERNAME:?'DOCKERHUB_USERNAME is required'}"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
IMAGE_NAME="dojoengine" | |
IMAGE_TAG="latest" | |
DOCKERHUB_USERNAME="your_dockerhub_username" | |
IMAGE_NAME="${DOCKER_IMAGE_NAME:-dojoengine}" | |
IMAGE_TAG="${DOCKER_IMAGE_TAG:-latest}" | |
DOCKERHUB_USERNAME="${DOCKERHUB_USERNAME:?'DOCKERHUB_USERNAME is required'}" |
katana: | ||
image: dojoengine:latest | ||
command: katana --dev --dev.no-fee --http.cors_origins "*" --http.addr 0.0.0.0 | ||
ports: | ||
- "5050:5050" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance the katana service configuration, sensei!
Add health check, restart policy, and resource limits for better reliability:
katana:
image: dojoengine:latest
command: katana --dev --dev.no-fee --http.cors_origins "*" --http.addr 0.0.0.0
ports:
- "5050:5050"
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:5050/is_alive"]
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ restart: unless-stopped
+ deploy:
+ resources:
+ limits:
+ memory: 1G
+ reservations:
+ memory: 512M
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
katana: | |
image: dojoengine:latest | |
command: katana --dev --dev.no-fee --http.cors_origins "*" --http.addr 0.0.0.0 | |
ports: | |
- "5050:5050" | |
katana: | |
image: dojoengine:latest | |
command: katana --dev --dev.no-fee --http.cors_origins "*" --http.addr 0.0.0.0 | |
ports: | |
- "5050:5050" | |
healthcheck: | |
test: ["CMD", "curl", "-f", "http://localhost:5050/is_alive"] | |
interval: 30s | |
timeout: 10s | |
retries: 3 | |
restart: unless-stopped | |
deploy: | |
resources: | |
limits: | |
memory: 1G | |
reservations: | |
memory: 512M |
torii: | ||
image: dojoengine:latest | ||
command: torii --config /etc/torii/torii.toml | ||
volumes: | ||
- ./torii.toml:/etc/torii/torii.toml | ||
ports: | ||
- "8080:8080" | ||
- "9090:9090" | ||
- "9091:9091" | ||
- "9092:9092" | ||
- "9200:9200" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance the torii service configuration, sensei!
Add dependency on katana, health check, and resource management:
torii:
image: dojoengine:latest
command: torii --config /etc/torii/torii.toml
volumes:
- ./torii.toml:/etc/torii/torii.toml
ports:
- "8080:8080"
- "9090:9090"
- "9091:9091"
- "9092:9092"
- "9200:9200"
+ depends_on:
+ katana:
+ condition: service_healthy
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ restart: unless-stopped
+ deploy:
+ resources:
+ limits:
+ memory: 1G
+ reservations:
+ memory: 512M
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
torii: | |
image: dojoengine:latest | |
command: torii --config /etc/torii/torii.toml | |
volumes: | |
- ./torii.toml:/etc/torii/torii.toml | |
ports: | |
- "8080:8080" | |
- "9090:9090" | |
- "9091:9091" | |
- "9092:9092" | |
- "9200:9200" | |
torii: | |
image: dojoengine:latest | |
command: torii --config /etc/torii/torii.toml | |
volumes: | |
- ./torii.toml:/etc/torii/torii.toml | |
ports: | |
- "8080:8080" | |
- "9090:9090" | |
- "9091:9091" | |
- "9092:9092" | |
- "9200:9200" | |
depends_on: | |
katana: | |
condition: service_healthy | |
healthcheck: | |
test: ["CMD", "curl", "-f", "http://localhost:8080/health"] | |
interval: 30s | |
timeout: 10s | |
retries: 3 | |
restart: unless-stopped | |
deploy: | |
resources: | |
limits: | |
memory: 1G | |
reservations: | |
memory: 512M |
LABEL description="Dojo is a provable game engine and toolchain for building onchain games and autonomous worlds with Cairo" \ | ||
authors="tarrence <[email protected]>" \ | ||
source="https://github.com/dojoengine/dojo" \ | ||
documentation="https://book.dojoengine.org/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add ENTRYPOINT and default CMD, sensei!
Use tini as entry point and set a default command:
LABEL description="Dojo is a provable game engine and toolchain for building onchain games and autonomous worlds with Cairo" \
authors="tarrence <[email protected]>" \
source="https://github.com/dojoengine/dojo" \
documentation="https://book.dojoengine.org/"
+
+ENTRYPOINT ["/tini", "--"]
+CMD ["katana", "--help"]
Committable suggestion skipped: line range outside the PR's diff.
RUN apt-get update && apt install -y git libtool automake autoconf make tini curl | ||
|
||
## install dojoengine | ||
RUN curl -L https://install.dojoengine.org | bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Secure the package installation and script download, sensei!
Add checksum verification and cleanup unnecessary packages:
-RUN apt-get update && apt install -y git libtool automake autoconf make tini curl
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends \
+ git=1:2.39.2-1.1 \
+ libtool=2.4.7-5 \
+ automake=1:1.16.5-1.3 \
+ autoconf=2.71-3 \
+ make=4.3-4.1 \
+ tini=0.19.0-1 \
+ curl=7.88.1-10+deb12u5 \
+ ca-certificates && \
+ apt-get clean && \
+ rm -rf /var/lib/apt/lists/*
-RUN curl -L https://install.dojoengine.org | bash
+RUN curl -fsSL https://install.dojoengine.org -o install.sh && \
+ echo "${DOJO_INSTALLER_SHA256} install.sh" | sha256sum -c && \
+ bash install.sh && \
+ rm install.sh
Committable suggestion skipped: line range outside the PR's diff.
FROM debian:bookworm-slim as base | ||
|
||
COPY --from=builder /usr/bin/tini /tini | ||
COPY --from=builder /root/.dojo/bin/katana /usr/local/bin/katana | ||
COPY --from=builder /root/.dojo/bin/sozo /usr/local/bin/sozo | ||
COPY --from=builder /root/.dojo/bin/torii /usr/local/bin/torii |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a non-root user and set proper permissions, sensei!
Add a non-root user for better security:
FROM debian:bookworm-slim as base
+RUN groupadd -r dojo && useradd -r -g dojo dojo
+
COPY --from=builder /usr/bin/tini /tini
COPY --from=builder /root/.dojo/bin/katana /usr/local/bin/katana
COPY --from=builder /root/.dojo/bin/sozo /usr/local/bin/sozo
COPY --from=builder /root/.dojo/bin/torii /usr/local/bin/torii
+
+RUN chown -R dojo:dojo /usr/local/bin/katana /usr/local/bin/sozo /usr/local/bin/torii && \
+ chmod +x /tini /usr/local/bin/katana /usr/local/bin/sozo /usr/local/bin/torii
+
+USER dojo
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
FROM debian:bookworm-slim as base | |
COPY --from=builder /usr/bin/tini /tini | |
COPY --from=builder /root/.dojo/bin/katana /usr/local/bin/katana | |
COPY --from=builder /root/.dojo/bin/sozo /usr/local/bin/sozo | |
COPY --from=builder /root/.dojo/bin/torii /usr/local/bin/torii | |
FROM debian:bookworm-slim as base | |
RUN groupadd -r dojo && useradd -r -g dojo dojo | |
COPY --from=builder /usr/bin/tini /tini | |
COPY --from=builder /root/.dojo/bin/katana /usr/local/bin/katana | |
COPY --from=builder /root/.dojo/bin/sozo /usr/local/bin/sozo | |
COPY --from=builder /root/.dojo/bin/torii /usr/local/bin/torii | |
RUN chown -R dojo:dojo /usr/local/bin/katana /usr/local/bin/sozo /usr/local/bin/torii && \ | |
chmod +x /tini /usr/local/bin/katana /usr/local/bin/sozo /usr/local/bin/torii | |
USER dojo |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2906 +/- ##
=======================================
Coverage 55.82% 55.82%
=======================================
Files 449 449
Lines 57824 57824
=======================================
Hits 32283 32283
Misses 25541 25541 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @847850277, thank you but not sure on how relevant this is, there's already a docker to build and work with dojo + a dev container.
Will close but don't hesitate to comment if you have further questions, or don't hesitate to pick an open issue. 👍
thanks! sir,I found it docker-images |
Description
Hi, @glihm Docker support has been provided for Dojo. Please review it when you have free time
add docker folder to support build docker image && run docker-compose with config
close #2902