Files
bitmagnet/docker-compose.yml
mgdigital c1e1d86095 Add gluetun configuration example (#83)
* Add gluetun configuration example and replace docker-compose.dev.yml with docker-compose.yml full featured example; update docsite
2023-11-29 22:02:29 +00:00

220 lines
6.1 KiB
YAML

# This is a full-featured example for running bitmagnet through a gluetun VPN connection with Grafana/Prometheus observability services.
# See https://bitmagnet.io/setup/installation.html for a minimal docker-compose example.
services:
bitmagnet:
container_name: bitmagnet
image: ghcr.io/bitmagnet-io/bitmagnet:latest
volumes:
- ./:/app
# Mount data folder (currently only used for logs when file rotation is enabled):
- ./data/bitmagnet:/root/.local/share/bitmagnet
restart: unless-stopped
environment:
# Enable logging to rotating files for ingest to Loki:
- LOG_FILE_ROTATOR_ENABLED=true
- POSTGRES_HOST=postgres
- POSTGRES_PASSWORD=postgres
- REDIS_ADDR=redis:6379
# - TMDB_API_KEY=your_api_key
network_mode: service:gluetun
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
command:
- worker
- run
# Run all workers:
- --all
# Or enable individual workers:
# - --keys=http_server
# - --keys=queue_server
# - --keys=dht_crawler
gluetun:
container_name: bitmagnet-gluetun
image: qmcgaw/gluetun:latest
cap_add:
- NET_ADMIN
ports:
# The bitmagnet ports must be exposed by the gluetun container:
- "3333:3333"
# BitTorrent ports:
- "3334:3334/tcp"
- "3334:3334/udp"
env_file:
# .env file containing your personal gluetun/VPN account config and credentials:
# (See https://github.com/qdm12/gluetun-wiki/tree/main/setup/providers)
- .env.gluetun
restart: always
# Host names must be manually mapped here for bitmagnet to resolve them:
extra_hosts:
- "postgres:192.168.55.11"
- "redis:192.168.55.12"
networks:
bitmagnet:
ipv4_address: 192.168.55.10
postgres:
image: postgres:16-alpine
container_name: bitmagnet-postgres
volumes:
- ./data/postgres:/var/lib/postgresql/data
networks:
bitmagnet:
ipv4_address: 192.168.55.11
ports:
- "5432:5432"
restart: unless-stopped
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=bitmagnet
- PGUSER=postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
start_period: 20s
redis:
image: redis:7-alpine
container_name: bitmagnet-redis
volumes:
- ./data/redis:/data
ports:
- "6379:6379"
restart: unless-stopped
entrypoint:
- redis-server
- --save 60 1
networks:
bitmagnet:
ipv4_address: 192.168.55.12
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
start_period: 20s
# Optional observability services:
# (ensure you have the config files in the `observability` directory in your project root)
# Visualization and dashboards:
grafana:
container_name: bitmagnet-grafana
image: grafana/grafana:latest
environment:
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
volumes:
- ./data/grafana:/var/lib/grafana
# Provisioned data sources and dashboards:
- ./observability/grafana.datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
- ./observability/grafana.dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml
- ./observability/grafana-dashboards:/etc/dashboards
ports:
- "3000:3000"
networks:
- bitmagnet
# Metrics and logs scraping:
grafana-agent:
container_name: bitmagnet-grafana-agent
image: grafana/agent:latest
volumes:
- ./data/bitmagnet/logs:/var/log/bitmagnet
# Mount the logs and metrics scraping configurations:
- ./observability/grafana-agent.config.river:/etc/agent-config/config.river
command:
- run
- /etc/agent-config/config.river
- --server.http.listen-addr=0.0.0.0:12345
environment:
HOSTNAME: grafana-agent
AGENT_MODE: flow
LOKI_HOST: loki:3100
POSTGRES_HOST: postgres:5432
REDIS_HOST: redis:6379
# The bitmagnet host must be mapped to the gluetun container:
extra_hosts:
- "bitmagnet:192.168.55.10"
ports:
- "12345:12345"
depends_on:
- gluetun
- loki
networks:
- bitmagnet
# Metrics storage and aggregation:
prometheus:
image: prom/prometheus:latest
container_name: bitmagnet-prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
ports:
- 9090:9090
# The bitmagnet host must be mapped to the gluetun container:
extra_hosts:
- "bitmagnet:192.168.55.10"
restart: unless-stopped
volumes:
- ./data/prometheus:/prometheus
- ./observability/prometheus.config.yaml:/etc/prometheus/prometheus.yml
networks:
- bitmagnet
# Log storage and aggregation:
loki:
container_name: bitmagnet-loki
image: grafana/loki:latest
ports:
- "3100:3100"
volumes:
- ./data/loki:/loki
- ./observability/loki.config.yaml:/etc/loki/local-config.yaml
command: -config.file=/etc/loki/local-config.yaml
networks:
- bitmagnet
# Runtime profiling:
pyroscope:
container_name: bitmagnet-pyroscope
image: grafana/pyroscope:latest
deploy:
restart_policy:
condition: on-failure
ports:
- "4040:4040"
command:
- "server"
volumes:
- ./observability/pyroscope.config.yaml:/etc/pyroscope/server.yaml
- ./data/pyroscope:/var/lib/pyroscope
networks:
- bitmagnet
# Prometheus metrics for Postgres:
postgres-exporter:
image: prometheuscommunity/postgres-exporter:latest
container_name: bitmagnet-postgres-exporter
ports:
- 9187:9187
environment:
DATA_SOURCE_NAME: "postgresql://postgres:postgres@postgres:5432/bitmagnet?sslmode=disable"
links:
- postgres
- prometheus
networks:
- bitmagnet
networks:
bitmagnet:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.55.0/24
gateway: 192.168.55.1