-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||
FROM debian:bookworm-slim as builder | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
RUN apt-get update && apt install -y git libtool automake autoconf make tini curl | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
## install dojoengine | ||||||||||||||||||||||||||||||||||||||||
RUN curl -L https://install.dojoengine.org | bash | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
SHELL ["/bin/bash", "-c"] | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
RUN source /root/.bashrc && dojoup | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+12
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
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/" | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+19
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"]
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,20 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: '3.8' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
services: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
katana: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
image: dojoengine:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command: katana --dev --dev.no-fee --http.cors_origins "*" --http.addr 0.0.0.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- "5050:5050" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+9
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,15 @@ | ||||||||||||||||||
#!/bin/bash | ||||||||||||||||||
|
||||||||||||||||||
# Define the image name and tag | ||||||||||||||||||
IMAGE_NAME="dojoengine" | ||||||||||||||||||
IMAGE_TAG="latest" | ||||||||||||||||||
DOCKERHUB_USERNAME="your_dockerhub_username" | ||||||||||||||||||
Comment on lines
+4
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
# Build the Docker image | ||||||||||||||||||
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} . | ||||||||||||||||||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
# Log in to Docker Hub | ||||||||||||||||||
docker login --username ${DOCKERHUB_USERNAME} | ||||||||||||||||||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
# Push the Docker image to Docker Hub | ||||||||||||||||||
docker push ${IMAGE_NAME}:${IMAGE_TAG} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# The World address to index. | ||
world_address = "0x0525177c8afe8680d7ad1da30ca183e482cfcd6404c1e09d83fd3fa2994fd4b8" | ||
|
||
# Default RPC URL configuration | ||
rpc = "http://host.docker.internal:5050" | ||
|
||
# Database configuration | ||
# Optional: If not specified, uses in-memory database | ||
db_dir = "/tmp/torii" | ||
|
||
# External URL for GraphQL Playground | ||
# Optional: Used in hosted environments | ||
# external_url = "" | ||
|
||
# Whether to open World Explorer in browser | ||
# Optional: Defaults to false | ||
# explorer = false | ||
|
||
|
||
|
||
# Server Options | ||
[server] | ||
http_addr = "0.0.0.0" | ||
http_port = 8080 | ||
http_cors_origins = ["*"] | ||
|
||
# Relay Options | ||
[relay] | ||
port = 9090 # TCP & UDP Quic transport | ||
webrtc_port = 9091 # WebRTC transport | ||
websocket_port = 9092 # WebSocket transport | ||
# relay.local_key_path = "" # Optional: Path to identity key file, generated if none. | ||
# relay.cert_path = "" # Optional: Path to certificate file for WebRTC | ||
|
||
# Indexing Options | ||
[indexing] | ||
events_chunk_size = 1024 # Size of events page to fetch | ||
blocks_chunk_size = 10240 # Blocks to process before DB commit | ||
index_pending = true # Enable indexing pending blocks | ||
polling_interval = 500 # Polling interval in milliseconds | ||
max_concurrent_tasks = 100 # Maximum concurrent indexing tasks | ||
index_transactions = false # Whether to index world transactions | ||
contracts = [ # ERC contracts to index | ||
"erc20:0x1234", | ||
"erc721:0x5678" | ||
] | ||
|
||
# Events Options | ||
[events] | ||
raw = true # Whether to index raw events | ||
historical = [ # Historical event message tags | ||
"ns-E", | ||
"ns-EH" | ||
] | ||
|
||
# Metrics Options | ||
[metrics] | ||
metrics = true # Enable metrics server | ||
addr = "0.0.0.0" # Metrics server address | ||
port = 9200 # Metrics server port |
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: