Skip to content

Commit

Permalink
Added the Docker Compose setup for local development
Browse files Browse the repository at this point in the history
  • Loading branch information
SundarGowtham committed May 8, 2024
1 parent ddaf48a commit 8384767
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 1,139 deletions.
4 changes: 1 addition & 3 deletions devenv/LOCAL/[0]-DOCKER-COMPOSE/bitcoin/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ RUN apt-get update && apt-get install -y \
COPY --from=builder /bitcoin/bin/* /usr/local/bin

COPY default.conf /etc/nginx/conf.d/default.conf
EXPOSE 18443
EXPOSE 18444
EXPOSE 18433

ADD entrypoint.sh /usr/local/bin
RUN chmod a+x /usr/local/bin/entrypoint.sh

Expand Down
3 changes: 3 additions & 0 deletions devenv/LOCAL/[0]-DOCKER-COMPOSE/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
CWD=$(pwd)
docker compose -f $CWD/docker-compose.yml build
123 changes: 66 additions & 57 deletions devenv/LOCAL/[0]-DOCKER-COMPOSE/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.2'

services:
bitcoin:
image: bitcoin:latest
Expand All @@ -14,14 +12,13 @@ services:
- 18443:18443
- 18433:18433
environment:
- ENV='DEV'
- 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'
- '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'
postgres:
image: postgres:15-alpine
container_name: postgres
Expand All @@ -38,21 +35,24 @@ services:
ports:
- 3306:3306
environment:
- MYSQL_DATABASE='mempool'
- MYSQL_USER='mempool'
- MYSQL_PASSWORD='mempool'
- MYSQL_ROOT_PASSWORD='admin'
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASSWORD: "mempool"
MYSQL_ROOT_PASSWORD: "admin"
bitcoin-miner:
image: miner:latest
container_name: miner
image: bitcoin-miner-sidecar:latest
container_name: bitcoin-miner-sidecar
stop_grace_period: 5s
build:
context: ./bitcion-miner-sidecar/docker
context: ./bitcoin-miner-sidecar/docker
depends_on:
- bitcoin
environment:
INIT_BTC_BLOCKS: 200
BTC_BLOCK_GEN_TIME: 10
BITCOIN_RPC_HOST: "bitcoin"
BITCOIN_RPC_PORT: "18443"
MINER_ADDRESS: "n3GRiDLKWuKLCw1DZmV75W1mE35qmW2tQm"
stacks:
image: stacks:latest
container_name: stacks
Expand All @@ -66,8 +66,34 @@ services:
- bitcoin
- bitcoin-miner
environment:
- STACKS_LOG_DEBUG=0
- STACKS_LOG_JSON=0
STACKS_LOG_DEBUG: 0
STACKS_LOG_JSON: 0
LOCAL_PEER_SEED: "3fd68a8fcab004754d6fee4756dd9c84ad64ee19a11aa9930893540e1357696f2f73957cd6e92797d7a66d1d3ae4a4ea752a8924fe028f1fc2c06b9d6d0ee0ad"
STACKS_WORKING_DIR: "/var/stacks"
MY_HTTP_AUTH_TOKEN: "helloworld"
SIGNER_ENDPOINT: "nakamoto-signer:30000"
MINER_KEY: "19ec1c3e31d139c989a23a27eac60d1abfad5277d3ae9604242514c738258efa01"
BTC_NODE_RPC_HOST: "bitcoin"
BTC_NODE_RPC_USER: "devnet"
BTC_NODE_RPC_PASSWORD: "devnet"
nakamoto-signer:
image: nakamoto-signer:latest
container_name: nakamoto-signer
stop_grace_period: 5s
build:
context: ./nakamoto-signer/docker
ports:
- 30000:30000
depends_on:
- bitcoin
- bitcoin-miner
environment:
SIGNER_ENDPOINT: "0.0.0.0:30000"
MY_HTTP_AUTH_TOKEN: "helloworld"
STACKS_PRIVATE_KEY: "30947cbe3a7942ad502fceb66253191ad08db4ec4cddf66eba7e9ce3d73dd3ca01"
STACKS_NODE_RPC_HOST: "stacks"
STACKS_NODE_RPC_PORT: "20443"
RUST_BACKTRACE: '1'
stacks-api:
image: stacks-api:latest
container_name: stacks-api
Expand Down Expand Up @@ -117,7 +143,7 @@ services:
- stacks-api
- postgres
environment:
- NEXT_PUBLIC_MAINNET_API_SERVER=http://127.0.0.1:3999
- NEXT_PUBLIC_MAINNET_API_SERVER=http://stacks-api:3999
electrs:
image: electrs:latest
container_name: electrs
Expand All @@ -130,29 +156,10 @@ services:
depends_on:
- bitcoin
- bitcoin-miner
environment:
- RUST_BACKTRACE='1'
- BITCOIN_RPC_HOST='bitcoin-regtest-service.bitcoin'
- BITCOIN_RPC_PORT='18443'
sbtc:
image: sbtc:latest
container_name: sbtc
stop_grace_period: 5s
restart: on-failure
build:
context: ./../
dockerfile: ./devenv/sbtc/docker/Dockerfile
depends_on:
- bitcoin
- stacks
- stacks-explorer
- stacks-api
- mempool-web
- bitcoin-miner
environment:
RUST_BACKTRACE: 1
volumes:
- $PWD/sbtc/docker/config.json:/romeo/config.json
BITCOIN_RPC_HOST: 'bitcoin'
BITCOIN_RPC_PORT: '18443'
mempool-web:
image: mempool/frontend:latest
container_name: mempool-web
Expand All @@ -165,8 +172,8 @@ services:
ports:
- 8083:8083
environment:
- FRONTEND_HTTP_PORT="8083"
- BACKEND_MAINNET_HTTP_HOST="mempool-backend-service.mempool"
FRONTEND_HTTP_PORT: "8083"
BACKEND_MAINNET_HTTP_HOST: "mempool-api"
command: "./wait-for mariadb:3306 --timeout=720 -- nginx -g 'daemon off;'"
mempool-api:
image: mempool/backend:latest
Expand All @@ -180,18 +187,20 @@ services:
ports:
- 8999:8999
environment:
- MEMPOOL_BACKEND='electrum'
- ELECTRUM_HOST='electrs-service.electrs'
- ELECTRUM_PORT='60401'
- ELECTRUM_TLS_ENABLED='false'
- CORE_RPC_HOST='bitcoin-regtest-service.bitcoin'
- CORE_RPC_PORT='18443'
- CORE_RPC_USERNAME='devnet'
- CORE_RPC_PASSWORD='devnet'
- DATABASE_ENABLED='true'
- DATABASE_HOST='mariadb-service.mariadb'
- DATABASE_DATABASE='mempool'
- DATABASE_USERNAME='mempool'
- DATABASE_PASSWORD='mempool'
- STATISTICS_ENABLED='true'
# Connect to electrs host
MEMPOOL_BACKEND: "electrum"
ELECTRUM_HOST: "electrs"
ELECTRUM_PORT: "60401"
ELECTRUM_TLS_ENABLED: "false"
# Connect to bitcoin rpc
CORE_RPC_HOST: "bitcoin"
CORE_RPC_PORT: "18443"
CORE_RPC_USERNAME: "devnet"
CORE_RPC_PASSWORD: "devnet"
DATABASE_ENABLED: "true"
DATABASE_HOST: "mariadb"
DATABASE_DATABASE: "mempool"
DATABASE_USERNAME: "mempool"
DATABASE_PASSWORD: "mempool"
STATISTICS_ENABLED: "true"
command: "./wait-for-it.sh mariadb:3306 --timeout=720 --strict -- ./start.sh"
2 changes: 2 additions & 0 deletions devenv/LOCAL/[0]-DOCKER-COMPOSE/down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
docker compose down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ electrs --network regtest \
--utxos-limit=2048 \
--db-dir="/opt" \
--cors="*" \
-vv
-vv
3 changes: 3 additions & 0 deletions devenv/LOCAL/[0]-DOCKER-COMPOSE/log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker logs -f $1
3 changes: 3 additions & 0 deletions devenv/LOCAL/[0]-DOCKER-COMPOSE/stacks-api/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM node:16-alpine
MAINTAINER Gowtham Sundar <[email protected]>

ARG GIT_URI='https://github.com/hirosystems/stacks-blockchain-api.git'
# ARG GIT_BRANCH='v7.3.0'
ARG GIT_BRANCH='v7.10.0-nakamoto.7'

WORKDIR /app
Expand All @@ -12,4 +13,6 @@ RUN echo "GIT_TAG=$(git tag --points-at HEAD)" >> .env
RUN npm config set unsafe-perm true && npm ci && npm run build && npm run build:docs && npm prune --production
RUN apk del .build-deps

EXPOSE 3999
EXPOSE 3700
CMD ["node", "./lib/index.js"]
35 changes: 6 additions & 29 deletions devenv/LOCAL/[0]-DOCKER-COMPOSE/stacks-explorer/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,28 @@
# --------------------------------------------------------
FROM node:18-alpine AS build
MAINTAINER Gowtham Sundar <[email protected]>

ARG REDIS_URL
ARG SEGMENT_WRITE_KEY
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_DSN
ARG SENTRY_LOG_LEVEL=warn
ARG NODE_ENV=production
ARG X_API_KEY
ARG RELEASE_TAG_NAME

# ARG STACKS_EXPLORER_VERSION='v1.170.1'
ARG GIT_URI='https://github.com/hirosystems/explorer.git'
ARG GIT_BRANCH='v1.170.1'

WORKDIR /app
RUN apk add --no-cache git python3 make g++
RUN git clone ${GIT_URI} -b ${GIT_BRANCH} .
RUN npm config set registry http://registry.npmjs.org
RUN npm install -g pnpm
RUN pnpm i
RUN pnpm build

# --------------------------------------------------------
FROM node:18-alpine

ARG REDIS_URL
ARG SEGMENT_WRITE_KEY
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_DSN
ARG SENTRY_LOG_LEVEL=warn
ARG NODE_ENV=production

# Set ENVs so they persist after image is built
ENV REDIS_URL=${REDIS_URL}
ENV SEGMENT_WRITE_KEY=${SEGMENT_WRITE_KEY}
ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}
ENV SENTRY_DSN=${SENTRY_DSN}
ENV SENTRY_LOG_LEVEL=${SENTRY_LOG_LEVEL}
ENV NODE_ENV=${NODE_ENV}
ENV X_API_KEY=${X_API_KEY}
ENV RELEASE_TAG_NAME=${RELEASE_TAG_NAME}

WORKDIR /app

COPY --from=build /app/next.config.js /app/next.config.js
COPY --from=build /app/public /app/public
COPY --from=build /app/.next/static /app/.next/static
COPY --from=build /app/.next/standalone /app


EXPOSE 3020
CMD [ "node", "server.js" ]
EXPOSE 3000
CMD [ "node", "server.js" ]
Loading

0 comments on commit 8384767

Please sign in to comment.