Files
purple-explorer/docker-compose.yml
davide 93bc951b6a Add Caddy reverse proxy with automatic HTTPS
- Add Caddyfile: proxies to explorer:3001, domain set via $DOMAIN env var
- docker-compose: new caddy service (ports 80/443/443-udp), persistent
  caddy_data/caddy_config volumes; remove direct explorer port binding
- .env.example: replace EXPLORER_PORT with DOMAIN

Set DOMAIN=localhost for local dev (HTTP), DOMAIN=your.domain.com for
production (Caddy fetches Let's Encrypt cert automatically)
2026-04-29 22:12:27 +02:00

130 lines
3.5 KiB
YAML

networks:
purple:
external: true # shared with purple-stack (bitcoinpurpled, electrumx)
explorer-internal: # isolates MongoDB from the outside world
name: purple-explorer-internal
volumes:
caddy_data: # TLS certificates — survives container restarts
caddy_config:
services:
mongodb:
image: mongo:7
container_name: purple-explorer-mongodb
restart: unless-stopped
networks:
- explorer-internal
volumes:
# Keep MongoDB data in this repository's ./db directory.
# Do not switch this back to a named Docker volume or the explorer will
# stop using the already-synced local database.
- type: bind
source: ./db
target: /data/db
bind:
create_host_path: true
- ./docker/mongo-init.sh:/docker-entrypoint-initdb.d/init.sh:ro
environment:
# Root admin (used only by the init script to bootstrap the app user)
MONGO_INITDB_ROOT_USERNAME: mongoadmin
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
# Passed into mongo-init.sh to create the explorer app user
MONGO_APP_USER: ${MONGO_USER}
MONGO_APP_PASS: ${MONGO_PASSWORD}
MONGO_APP_DB: ${MONGO_DATABASE:-explorerdb}
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
caddy:
image: caddy:2-alpine
container_name: purple-explorer-caddy
restart: unless-stopped
depends_on:
- explorer
networks:
- explorer-internal
ports:
- "0.0.0.0:80:80"
- "0.0.0.0:443:443"
- "0.0.0.0:443:443/udp" # HTTP/3
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
environment:
DOMAIN: ${DOMAIN}
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
explorer:
build: .
image: purple-explorer:local
container_name: purple-explorer
restart: unless-stopped
depends_on:
- mongodb
networks:
- purple # reach bitcoinpurpled:13495 for RPC
- explorer-internal
# Port 3001 is intentionally not published — Caddy proxies traffic
env_file: .env
command: web
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
sync-blocks:
image: purple-explorer:local
container_name: purple-explorer-sync-blocks
restart: unless-stopped
depends_on:
- mongodb
- explorer # ensures the image is built before this runs
networks:
- purple # reach bitcoinpurpled RPC
- explorer-internal
env_file: .env
command: sync-blocks
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# sync-markets: disabled until exchanges are configured in docker/settings.json.tmpl
# To enable: uncomment, configure markets_page.exchanges in the template, then redeploy.
# sync-markets:
# image: purple-explorer:local
# container_name: purple-explorer-sync-markets
# restart: unless-stopped
# depends_on: [mongodb]
# networks: [explorer-internal]
# env_file: .env
# command: sync-markets
sync-peers:
image: purple-explorer:local
container_name: purple-explorer-sync-peers
restart: unless-stopped
depends_on:
- mongodb
networks:
- purple # reach bitcoinpurpled for peer info
- explorer-internal
env_file: .env
command: sync-peers
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"