Skip to content
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

Adds local docker compose file #32

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Create a `.env` file to the root directory as indicated in the `.env.example` fi

Then, to set up the cluster simply run:

`docker compose up -d --build`
`bun run deploy-${ENV}`

Where `ENV` can be `local` or `prod`.

> Tip: to quickly test your changes back to back, rebuild the services use `docker compose down && docker compose up -d --build --force-recreate`.

Expand Down
16 changes: 14 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,26 @@ else
exit 1
fi

docker compose down && docker compose up --build -d --force-recreate
ENV="prod"
DOCKER_FILE="docker-compose.yaml"

if [ $# -ne 0 ]; then
if [ $1 = "local" ]; then
ENV="local"
DOCKER_FILE="docker-compose.local.yaml"
fi
fi

echo "Deploying the minting-server container network in $ENV mode..."

docker compose -f $DOCKER_FILE down && docker compose -f $DOCKER_FILE up --build -d --force-recreate

if [[ $? -ne 0 ]]; then
echo "ERROR: Failed to deploy the minting-server container network. Check your configuration and try again."
exit 1
fi

docker compose cp ./smart_contract_config.yaml request_processor:/usr/src/app
docker compose -f $DOCKER_FILE cp ./smart_contract_config.yaml request_processor:/usr/src/app

if [[ $? -ne 0 ]]; then
echo "ERROR: Failed to copy smart_contract_config.yaml to the request_processor container."
Expand Down
68 changes: 68 additions & 0 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
services:
queue:
image: redis:latest
ports:
- "6379:6379"
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD}
volumes:
- queue_data:/data
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
request_handler:
build:
context: ./request_handler
dockerfile: Dockerfile
depends_on:
- queue
volumes:
- .:/usr/src/minting_server/request_handler
ports:
- "3000:3000"
environment:
- REDIS_HOST=queue
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- BUFFER_SIZE=${BUFFER_SIZE}
- STALE_BUFFER_TIMEOUT_MS=${STALE_BUFFER_TIMEOUT_MS}
- NODE_ENV=development
request_processor:
build:
context: ./request_processor
dockerfile: Dockerfile
depends_on:
- queue
environment:
- REDIS_HOST=queue
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- JOB_RETRIES=${JOB_RETRIES}
- JOB_RETRY_DELAY=${JOB_RETRY_DELAY}
- PACKAGE_ADDRESS=${PACKAGE_ADDRESS}
- MODULE_NAME=${MODULE_NAME}
- ADMIN_SECRET_KEY=${ADMIN_SECRET_KEY}
- ADMIN_CAP=${ADMIN_CAP}
- ADMIN_ADDRESS=${ADMIN_ADDRESS}
- PTE_COIN_BATCH_SIZE=${PTE_COIN_BATCH_SIZE}
- PTE_INITIAL_COIN_BALANCE=${PTE_INITIAL_COIN_BALANCE}
- PTE_MINIMUM_COIN_BALANCE=${PTE_MINIMUM_COIN_BALANCE}
- PTE_MAX_POOL_SIZE=${PTE_MAX_POOL_SIZE}
- NETWORK=${NETWORK}
- BULLMQ_WORKER_CONCURRENCY=${BULLMQ_WORKER_CONCURRENCY}
- NODE_ENV=development
deploy:
mode: replicated
# Change the number of replicas to increase the number of request processors
# Warning! You will need a different admin account for each request processor
# because Sui's paralleltransactionexecutor assumes that there is only one instance
# of it per account.
replicas: 1
notifier:
build:
context: ./notifier
dockerfile: Dockerfile
depends_on:
- request_processor
ports:
- "3001:3001"
volumes:
queue_data:
2 changes: 1 addition & 1 deletion notifier/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
FROM oven/bun:latest AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
},
"scripts": {
"fix-format": "bun prettier . --write",
"check-format": "bun prettier . --check"
"check-format": "bun prettier . --check",
"deploy-local": "chmod u+x deploy.sh && ./deploy.sh local",
"deploy-prod": "chmod u+x deploy.sh && ./deploy.sh"
}
}
2 changes: 1 addition & 1 deletion request_handler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
FROM oven/bun:latest AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
Expand Down
2 changes: 1 addition & 1 deletion request_processor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
FROM oven/bun:latest AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
Expand Down
Loading