-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
169 lines (162 loc) · 4.88 KB
/
docker-compose.yml
File metadata and controls
169 lines (162 loc) · 4.88 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
162
163
164
165
166
167
168
169
# Docker Compose for BitNet-rs
#
# Usage:
# docker compose up bitnet-cpu # CPU inference server
# docker compose --profile gpu up # GPU inference server
# docker compose --profile production up # CPU + nginx reverse proxy
# docker compose --profile monitoring up # CPU + Prometheus + Grafana
#
# Environment variables (set in shell or .env file):
# GIT_SHA - Git commit hash for OCI labels
# GIT_BRANCH - Git branch name for OCI labels
# GIT_DESCRIBE - Git describe output for version label
# BITNET_THREADS - Rayon thread count (default: 4)
# CUDA_DEVICE - GPU device index (default: 0)
# ─────────────────────────────────────────────────────────────────
services:
# ── CPU inference server ──────────────────────────────────────────
bitnet-cpu:
build:
context: .
dockerfile: Dockerfile
target: runtime
args:
VCS_REF: ${GIT_SHA:-unknown}
VCS_BRANCH: ${GIT_BRANCH:-unknown}
VCS_DESCRIBE: ${GIT_DESCRIBE:-unknown}
image: bitnet-rs:cpu
container_name: bitnet-cpu
ports:
- "8080:8080"
volumes:
- ./models:/models:ro # Model files (read-only)
- bitnet_data:/data # Writable data (receipts, logs)
environment:
- RUST_LOG=info # Log level: error|warn|info|debug|trace
- BITNET_THREADS=${BITNET_THREADS:-4}
command: ["server"]
restart: unless-stopped
user: "10001:10001"
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
read_only: true
tmpfs:
- /tmp:rw,noexec,nosuid,nodev
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
deploy:
resources:
limits:
cpus: '4'
memory: 8G
reservations:
cpus: '2'
memory: 4G
# ── GPU (CUDA) inference server ───────────────────────────────────
bitnet-gpu:
build:
context: .
dockerfile: Dockerfile
target: runtime-gpu
args:
VCS_REF: ${GIT_SHA:-unknown}
VCS_BRANCH: ${GIT_BRANCH:-unknown}
VCS_DESCRIBE: ${GIT_DESCRIBE:-unknown}
image: bitnet-rs:gpu
container_name: bitnet-gpu
ports:
- "8081:8080"
volumes:
- ./models:/models:ro
- bitnet_data_gpu:/data
environment:
- RUST_LOG=info
- CUDA_VISIBLE_DEVICES=${CUDA_DEVICE:-0}
command: ["server"]
restart: unless-stopped
user: "10001:10001"
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
read_only: true
tmpfs:
- /tmp:rw,noexec,nosuid,nodev
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
deploy:
resources:
limits:
cpus: '4'
memory: 16G
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
profiles:
- gpu
# ── Reverse proxy (optional) ─────────────────────────────────────
nginx:
image: nginx:1.25-alpine
container_name: bitnet-lb
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certs:/etc/nginx/certs:ro
depends_on:
- bitnet-cpu
restart: unless-stopped
profiles:
- production
# ── Monitoring (optional) ─────────────────────────────────────────
prometheus:
image: prom/prometheus:v2.53.0
container_name: bitnet-prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
restart: unless-stopped
profiles:
- monitoring
grafana:
image: grafana/grafana:10.4.3
container_name: bitnet-grafana
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./grafana/datasources:/etc/grafana/provisioning/datasources:ro
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
restart: unless-stopped
profiles:
- monitoring
volumes:
bitnet_data:
bitnet_data_gpu:
prometheus_data:
grafana_data:
networks:
default:
name: bitnet-network
driver: bridge