# Services that run on the single, centralized bmon server instance. # # Environment is injected from the .env file, which is generated by # `./infra/bmon_infra/config.py`. version: '3.5' x-service-config: &service environment: &env BMON_DEBUG: BMON_HOSTS_FILE: BMON_HOSTNAME: DB_HOST: DB_PASSWORD: BITCOIN_RPC_HOST: BITCOIN_RPC_PASSWORD: BITCOIN_RPC_PORT: BITCOIN_RPC_USER: BITCOIN_GITSHA: BITCOIN_GITREF: BITCOIN_VERSION: BITCOIN_FLAGS: BITCOIN_PRUNE: BITCOIN_DBCACHE: BITCOIND_VERSION_PATH: BMON_REDIS_SERVER_URL: BMON_REDIS_HOST: SENTRY_DSN: PYTHONUNBUFFERED: 1 x-redis-config: &redis-config image: docker.io/library/redis user: "${UID}" ports: - 6379:6379 volumes: - ${ENV_ROOT}/redis/data:/data # Configure redis for persistence with AOF; # See https://redis.io/docs/manual/persistence/ command: redis-server --appendonly yes --loglevel warning services: # bmon server containers # ----------------------------------------------- db: profiles: ["server"] user: "${UID}" image: docker.io/library/postgres:14-bullseye environment: POSTGRES_DB: bmon POSTGRES_USER: bmon POSTGRES_PASSWORD: ${DB_PASSWORD} volumes: - ${ENV_ROOT}/postgres/data:/var/lib/postgresql/data - /etc/passwd:/etc/passwd:ro ports: - 5432:5432 redis: profiles: ["server"] <<: *redis-config grafana: profiles: ["server"] image: docker.io/grafana/grafana-enterprise:9.2.3 user: "${UID}" volumes: - ${ENV_ROOT}/grafana/etc:/etc/grafana - ${ENV_ROOT}/grafana/var:/var/lib/grafana links: - prom - alertman - loki ports: - 3000:3000 loki: profiles: ["server"] image: docker.io/grafana/loki user: "${UID}" volumes: - ${ENV_ROOT}/loki:/loki - ${ENV_ROOT}/loki/etc:/etc/loki links: - alertman command: -config.file=/etc/loki/local-config.yaml ports: - 3100:3100 prom: profiles: ["server"] image: docker.io/prom/prometheus user: "${UID}" volumes: - ${ENV_ROOT}/prom/etc:/etc/prometheus - ${ENV_ROOT}/prom/data:/prometheus links: - alertman ports: - 9090:9090 alertman: profiles: ["server"] image: docker.io/prom/alertmanager user: "${UID}:1000" volumes: - ${ENV_ROOT}/alertman/config.yml:/etc/alertmanager/config.yml - ${ENV_ROOT}/alertman/data:/alertmanager command: --config.file=/etc/alertmanager/config.yml --storage.path=/alertmanager ports: - 9093:9093 web: &web_config profiles: ["server"] user: "${UID}" build: context: . dockerfile: ./docker/py.Dockerfile image: docker.io/jamesob/bmon:latest environment: <<: *env RUN_DB_MIGRATIONS: 1 WAIT_FOR: "${DB_HOST}:5432" ports: - 8080:8080 volumes: - ./:/src links: - db command: ./manage.py runserver 0.0.0.0:8080 shell: image: docker.io/jamesob/bmon:latest profiles: ["ops"] environment: <<: *env WAIT_FOR: "${DB_HOST}:5432" IPYTHONDIR: /var/lib/ipython volumes: - ./:/src - ${ENV_ROOT}/ipython:/var/lib/ipython command: ./manage.py shell server-task-worker: profiles: ["server"] user: "${UID}" image: docker.io/jamesob/bmon:latest environment: <<: *env WAIT_FOR: "${DB_HOST}:5432,${BMON_REDIS_HOST}:6379" volumes: - ./:/src links: - db - redis command: huey_consumer.py bmon.server_tasks.server_q -w 8 server-mempool-task-worker: profiles: ["server"] user: "${UID}" image: docker.io/jamesob/bmon:latest environment: <<: *env WAIT_FOR: "${DB_HOST}:5432,${BMON_REDIS_HOST}:6379" volumes: - ./:/src links: - db - redis command: huey_consumer.py bmon.server_tasks.mempool_q -w 8 -q server-monitor: profiles: ["server"] user: "${UID}" image: docker.io/jamesob/bmon:latest environment: <<: *env WAIT_FOR: "${BMON_REDIS_HOST}:6379,${DB_HOST}:5432" BMON_REDIS_URL: volumes: - ./:/src command: bmon-server-monitor ports: - 9334:9334 bitcoind-exporter: profiles: ["bitcoind"] image: jamesob/bitcoin-prometheus-exporter:latest environment: <<: *env BITCOIN_RPC_HOST: links: - bitcoind ports: - 9332:9332 # bitcoind node containers # ----------------------------------------------- bitcoind: profiles: ["bitcoind"] image: ${BITCOIN_DOCKER_TAG} user: "${UID}" volumes: - ${ENV_ROOT}/bitcoin/data:/bitcoin/data command: bitcoind -datadir=/bitcoin/data ${BITCOIN_FLAGS} ports: - 8332:8332 - 8333:8333 promtail: profiles: ["bitcoind"] image: docker.io/grafana/promtail user: "${UID}" environment: BMON_REDIS_LOCAL_URL: BMON_REDIS_SERVER_URL: WAIT_FOR: "${LOKI_HOST}:${LOKI_PORT}" volumes: - ${ENV_ROOT}/promtail:/etc/promtail - ${BITCOIN_DATA_PATH}:/bitcoin/data command: --config.file=/etc/promtail/config.yml links: - bitcoind redis-bitcoind: profiles: ["prod-bitcoind"] <<: *redis-config bitcoind-task-worker: &bitcoind-worker profiles: ["bitcoind"] user: "${UID}" image: docker.io/jamesob/bmon:latest # We have to repeat the build section here because the `web` container won't # build on bitcoind hosts, so we have to have at least one container configured # to. build: context: . dockerfile: ./docker/py.Dockerfile environment: <<: *env BMON_REDIS_LOCAL_URL: WAIT_FOR: "${BMON_REDIS_HOST}:6379,${BMON_REDIS_LOCAL_HOST}:6379" CHAINCODE_GCP_CRED_PATH: volumes: - ./:/src - ${ENV_ROOT}/bmon/mempool-activity-cache:/mempool-activity-cache - ${BITCOIND_VERSION_PATH}:/bitcoin-version:ro # Can't have this as a dependency because of local dev. # links: # - redis-bitcoind command: huey_consumer.py bmon.bitcoind_tasks.events_q -w 3 bitcoind-mempool-worker: <<: *bitcoind-worker volumes: - ./:/src - ${ENV_ROOT}/bmon/mempool-activity-cache:/mempool-activity-cache - ${ENV_ROOT}/bmon/credentials/chaincode-gcp.json:${CHAINCODE_GCP_CRED_PATH} - ${BITCOIND_VERSION_PATH}:/bitcoin-version:ro # Consume mempool activity in its own worker since it's so high volume. # Tell huey to -q to avoid lots of noise. command: huey_consumer.py bmon.bitcoind_tasks.mempool_q -w 3 -q bitcoind-watcher: profiles: ["bitcoind"] user: "${UID}" image: docker.io/jamesob/bmon:latest environment: <<: *env BMON_REDIS_LOCAL_URL: BMON_BITCOIND_LOG_PATH: /bitcoin-data/debug.log WAIT_FOR: "${BMON_REDIS_HOST}:6379,${DB_HOST}:5432" volumes: - ./:/src - ${BITCOIN_DATA_PATH}:/bitcoin-data:ro - ${BITCOIND_VERSION_PATH}:/bitcoin-version:ro links: - bitcoind - bitcoind-task-worker command: bmon-watch-bitcoind-logs bitcoind-monitor: profiles: ["bitcoind"] user: "${UID}" image: docker.io/jamesob/bmon:latest environment: <<: *env WAIT_FOR: "${BMON_REDIS_LOCAL_HOST}:6379,${DB_HOST}:5432" BMON_REDIS_LOCAL_URL: BMON_BITCOIND_LOG_PATH: /bitcoin-data/debug.log volumes: - ./:/src - ${ENV_ROOT}/bmon/mempool-activity-cache:/mempool-activity-cache - ${BITCOIN_DATA_PATH}:/bitcoin-data - ${BITCOIND_VERSION_PATH}:/bitcoin-version:ro command: bmon-bitcoind-monitor ports: - 9333:9333 node-exporter: # only monitor this stuff in prod since its mountpoint needs are zealous. profiles: ["prod"] image: prom/node-exporter:latest restart: unless-stopped volumes: - /proc:/host/proc:ro - /sys:/host/sys:ro - /:/rootfs:ro command: - '--path.procfs=/host/proc' - '--path.rootfs=/rootfs' - '--path.sysfs=/host/sys' - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)' ports: - 9100:9100 # dev containers # ----------------------------------------------- test: profiles: ["dev"] user: "${UID}" image: docker.io/jamesob/bmon:test-latest build: context: . dockerfile: ./docker/py.Dockerfile args: PYTHON_PKG: .[tests] environment: <<: *env DJANGO_SETTINGS_MODULE: bmon.settings_test WAIT_FOR: "${BMON_REDIS_HOST}:6379,${DB_HOST}:5432" ports: - 8080:8080 volumes: - ./:/src links: - db - bitcoind - redis command: ./manage.py runserver 0.0.0.0:8080 js: profiles: ["dev"] image: js user: "${UID}" build: context: ./frontend environment: <<: *env volumes: - ./frontend:/src - js_node_modules:/node_modules - ./frontend-build:/build command: yarn run build bitcoind-02: profiles: ["dev"] image: ${BITCOIN_DOCKER_TAG} user: "${UID}" volumes: - ${ENV_ROOT}/bitcoin-02/data:/bitcoin/data - ${ENV_ROOT}/bitcoin-02/data/bitcoin.conf:/bitcoin/bitcoin.conf command: bitcoind -datadir=/bitcoin/data ${BITCOIN_FLAGS} volumes: js_node_modules: