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

Split devenv into different node profiles. #307

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
51 changes: 51 additions & 0 deletions devenv/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
show_help() {
echo "Usage: $0 [-h|--help] <profile>"
echo "Available profiles: min (bitcoin, stacks, electrs), full"
echo "Configs and runtimes may change depending on the profile."
exit 0
}

docker_runner() {
if [ "$profile" == "min" ]; then
docker compose -f min-docker-compose.yml $1 $2
elif [ "$profile" == "full" ]; then
docker compose $1 $2
else
echo "Invalid profile. Available profiles: min, full"
fi
}

run() {
local profile=""
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-h | --help)
show_help
;;
min | full)
if ! [ -z "$profile" ]; then
echo "Profile '$profile' already set"
show_help
exit 1
fi
profile="$1"
shift
;;
*)
echo "Unknown option: $1"
show_help
;;
esac
done

if [ -z "$profile" ]; then
echo "You must specify a profile (min or full)"
show_help
exit 1
fi

local subcommand=$(basename $0 .sh)
docker_runner $subcommand "$FLAGS"
}
104 changes: 15 additions & 89 deletions devenv/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,13 @@ version: '3.2'

services:
bitcoin:
image: bitcoin:latest
container_name: bitcoin
stop_grace_period: 5s
build:
context: ./bitcoin/docker
args:
VERSION: '25.0'
ports:
- 18444:18444
- 18443:18443
- 18433:18433
environment:
- 'BTC_NETWORK=regtest'
- 'BTC_DISABLEWALLET=0'
- 'BTC_TXINDEX=1'
- 'BTC_RPCBIND=0.0.0.0'
- 'BTC_RPCALLOWIP=0.0.0.0/0'
- 'BTC_RPCPASSWORD=devnet'
- 'BTC_RPCUSER=devnet'
extends:
file: min-docker-compose.yml
service: bitcoin
postgres:
image: postgres:15-alpine
container_name: postgres
stop_grace_period: 5s
ports:
- 5432:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
extends:
file: min-docker-compose.yml
service: postgres
mongodb:
image: mongo:6.0
container_name: mongodb
Expand Down Expand Up @@ -63,56 +42,13 @@ services:
INIT_BTC_BLOCKS: 200
BTC_BLOCK_GEN_TIME: 10
stacks:
image: stacks:latest
container_name: stacks
stop_grace_period: 5s
build:
context: ./stacks/docker
args:
STACKS_NODE_VERSION: '2.4.0.0.0'
GIT_URI: https://github.com/stacks-network/stacks-blockchain.git
GIT_BRANCH: develop
ports:
- 20444:20444
- 20443:20443
depends_on:
- bitcoin
- miner
environment:
- STACKS_LOG_DEBUG=0
- STACKS_LOG_JSON=0
extends:
file: min-docker-compose.yml
service: stacks
stacks-api:
image: stacks-api:latest
container_name: stacks-api
stop_grace_period: 5s
build:
context: ./stacks-api/docker
args:
GIT_URI: 'https://github.com/hirosystems/stacks-blockchain-api.git'
GIT_BRANCH: 'v7.3.0'
ports:
- 3999:3999
- 3700:3700
depends_on:
- postgres
- stacks
- bitcoin
environment:
- NODE_ENV=production
- GIT_TAG=master
- PG_HOST=postgres
- PG_PORT=5432
- PG_USER=postgres
- PG_PASSWORD=postgres
- PG_DATABASE=postgres
- STACKS_CHAIN_ID=0x80000000
- STACKS_CORE_EVENT_PORT=3700
- STACKS_CORE_EVENT_HOST=0.0.0.0
- STACKS_BLOCKCHAIN_API_PORT=3999
- STACKS_BLOCKCHAIN_API_HOST=0.0.0.0
- STACKS_CORE_RPC_HOST=stacks
- STACKS_CORE_RPC_PORT=20443
- API_DOCS_URL=http://localhost:3999/doc
extends:
file: min-docker-compose.yml
service: stacks-api
stacks-explorer:
image: stacks-explorer
container_name: stacks-explorer
Expand All @@ -133,19 +69,9 @@ services:
environment:
- NEXT_PUBLIC_MAINNET_API_SERVER=http://127.0.0.1:3999
electrs:
image: electrs:latest
container_name: electrs
stop_grace_period: 5s
build:
context: ./electrs/docker
ports:
- 60401:60401
- 3002:3002
depends_on:
- bitcoin
- miner
environment:
RUST_BACKTRACE: 1
extends:
file: min-docker-compose.yml
service: electrs
sbtc:
image: sbtc:latest
container_name: sbtc
Expand Down
8 changes: 7 additions & 1 deletion devenv/down.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#!/usr/bin/env bash
docker compose down

set -ueo >/dev/null

FLAGS=""
source ./common.sh

run $@
95 changes: 95 additions & 0 deletions devenv/min-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
version: '3.2'

services:
bitcoin:
image: bitcoin:latest
container_name: bitcoin
stop_grace_period: 5s
build:
context: ./bitcoin/docker
args:
VERSION: '25.0'
ports:
- 18444:18444
- 18443:18443
- 18433:18433
environment:
- 'BTC_NETWORK=regtest'
- 'BTC_DISABLEWALLET=0'
- 'BTC_TXINDEX=1'
- 'BTC_RPCBIND=0.0.0.0'
- 'BTC_RPCALLOWIP=0.0.0.0/0'
- 'BTC_RPCPASSWORD=devnet'
- 'BTC_RPCUSER=devnet'
electrs:
image: electrs:latest
container_name: electrs
stop_grace_period: 5s
build:
context: ./electrs/docker
ports:
- 60401:60401
- 3002:3002
depends_on:
- bitcoin
environment:
RUST_BACKTRACE: 1
stacks:
image: stacks:latest
container_name: stacks
stop_grace_period: 5s
build:
context: ./stacks/docker
args:
STACKS_NODE_VERSION: '2.4.0.0.0'
GIT_URI: https://github.com/stacks-network/stacks-blockchain.git
GIT_BRANCH: develop
ports:
- 20444:20444
- 20443:20443
depends_on:
- bitcoin
environment:
- STACKS_LOG_DEBUG=0
- STACKS_LOG_JSON=0
postgres:
image: postgres:15-alpine
container_name: postgres
stop_grace_period: 5s
ports:
- 5432:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
stacks-api:
image: stacks-api:latest
container_name: stacks-api
stop_grace_period: 5s
build:
context: ./stacks-api/docker
args:
GIT_URI: 'https://github.com/hirosystems/stacks-blockchain-api.git'
GIT_BRANCH: 'v7.3.0'
ports:
- 3999:3999
- 3700:3700
depends_on:
- postgres
- stacks
- bitcoin
environment:
- NODE_ENV=production
- GIT_TAG=master
- PG_HOST=postgres
- PG_PORT=5432
- PG_USER=postgres
- PG_PASSWORD=postgres
- PG_DATABASE=postgres
- STACKS_CHAIN_ID=0x80000000
- STACKS_CORE_EVENT_PORT=3700
- STACKS_CORE_EVENT_HOST=0.0.0.0
- STACKS_BLOCKCHAIN_API_PORT=3999
- STACKS_BLOCKCHAIN_API_HOST=0.0.0.0
- STACKS_CORE_RPC_HOST=stacks
- STACKS_CORE_RPC_PORT=20443
- API_DOCS_URL=http://localhost:3999/doc
11 changes: 6 additions & 5 deletions devenv/up.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

if [ $? -eq 0 ]; then
docker compose up -d
else
echo "Build failed, not starting devenv"
fi
set -ueo >/dev/null

FLAGS="-d --remove-orphans"
source ./common.sh

run $@
Loading