forked from pi-node/pi-node
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
161 lines (153 loc) · 4.39 KB
/
docker-compose.yml
File metadata and controls
161 lines (153 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Production-ready pi-supernode stack
# Supports Raspberry Pi (ARM) + x86 + Multi-arch
version: '3.8'
x-logging: &default-logging
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
compress: "true"
x-deploy: &default-deploy
resources:
limits:
memory: 1G
cpus: '1.0'
reservations:
memory: 512M
cpus: '0.5'
services:
# ========================================
# Main Supernode Service
# ========================================
pi-supernode:
build:
context: .
dockerfile: Dockerfile
args:
VERSION: ${PI_VERSION:-latest}
image: ghcr.io/kosasih/pi-supernode:${PI_VERSION:-latest}
container_name: pi-supernode
restart: unless-stopped
ports:
- "8080:8080/tcp" # HTTP API / Explorer
- "30001:30001/udp" # P2P Discovery
- "30001:30001/tcp" # P2P (TCP fallback)
- "31400:31400/tcp" # Legacy P2P
- "31401:31401/tcp" # Legacy RPC
volumes:
- supernode_data:/data
- ./config:/etc/supernode:ro
- supernode_logs:/app/logs
environment:
# 🚨 SECURITY: Use secrets or env files - NEVER hardcode!
- TZ=${TZ:-UTC}
- LOG_LEVEL=${LOG_LEVEL:-info}
- NODE_KEY_PATH=/data/node.key
- P2P_BIND=0.0.0.0:30001
- API_BIND=0.0.0.0:8080
- DATABASE_URL=postgresql://pi:${POSTGRES_PASSWORD}@db:5432/pi_supernode?sslmode=disable
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8080/health || wget --no-verbose --tries=1 --spider http://localhost:8080/ping || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
depends_on:
db:
condition: service_healthy
networks:
- supernode-net
logging: *default-logging
deploy: *default-deploy
# ========================================
# PostgreSQL Database (Production Config)
# ========================================
db:
image: postgres:16-alpine
container_name: pi-supernode-db
restart: unless-stopped
environment:
POSTGRES_DB: pi_supernode
POSTGRES_USER: pi
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init-db.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
ports:
- "5432:5432" # Remove in production!
healthcheck:
test: ["CMD-SHELL", "pg_isready -U pi -d pi_supernode"]
interval: 10s
timeout: 5s
retries: 5
networks:
- supernode-net
logging: *default-logging
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
# ========================================
# Redis (Caching/PubSub) - Optional
# ========================================
redis:
image: redis:7-alpine
container_name: pi-supernode-redis
restart: unless-stopped
command: redis-server --appendonly yes --maxmemory 128mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
networks:
- supernode-net
logging: *default-logging
# ========================================
# Traefik Reverse Proxy (Optional Production)
# ========================================
traefik:
image: traefik:v3.0
container_name: pi-supernode-traefik
restart: unless-stopped
command:
- --api.insecure=true
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
ports:
- "80:80"
- "8081:8080" # Traefik Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- supernode-net
labels:
- "traefik.enable=true"
- "traefik.http.routers.supernode.rule=Host(`supernode.local`)"
- "traefik.http.routers.supernode.entrypoints=web"
- "traefik.http.services.supernode.loadbalancer.server.port=8080"
# ========================================
# Volumes (Named & Persistent)
# ========================================
volumes:
supernode_data:
driver: local
postgres_data:
driver: local
redis_data:
driver: local
supernode_logs:
driver: local
# ========================================
# Networks
# ========================================
networks:
supernode-net:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16