Skip to content

Commit d6a9dee

Browse files
authored
Merge pull request #137 from NillionNetwork/feat/nilai_nilcc_integration
feat: nilAI <> nilCC integration
2 parents 2fb700f + e29ac40 commit d6a9dee

24 files changed

+519
-262
lines changed

.github/workflows/cicd.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,12 @@ jobs:
119119
# Copy secret into .env replacing the existing HF_TOKEN
120120
sed -i 's/HF_TOKEN=.*/HF_TOKEN=${{ secrets.HF_TOKEN }}/' .env
121121
122+
- name: Compose docker-compose.yml
123+
run: bash ./scripts/docker-composer.sh --dev -f docker/compose/docker-compose.llama-1b-gpu.ci.yml -o development-compose.yml
124+
122125
- name: Start Services
123126
run: |
124-
docker-compose -f docker-compose.yml \
125-
-f docker-compose.dev.yml \
126-
-f docker-compose.prod.yml \
127-
-f docker/compose/docker-compose.llama-1b-gpu.ci.yml \
128-
up -d
127+
docker-compose -f development-compose.yml up -d
129128
docker ps -a
130129
131130
- name: Wait for services to be healthy
@@ -149,11 +148,7 @@ jobs:
149148
150149
- name: Stop Services
151150
run: |
152-
docker-compose -f docker-compose.yml \
153-
-f docker-compose.dev.yml \
154-
-f docker-compose.prod.yml \
155-
-f docker/compose/docker-compose.llama-1b-gpu.ci.yml \
156-
down -v
151+
docker-compose -f development-compose.yml down -v
157152
158153
stop-runner:
159154
name: Stop self-hosted EC2 runner

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,6 @@ prometheus/data/*
175175

176176
private_key.key
177177
private_key.key.lock
178+
179+
development-compose.yml
180+
production-compose.yml

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,83 @@ docker compose -f docker-compose.yml \
8787
up -d
8888
```
8989

90-
### 2. Manual Component Deployment
90+
### 2. Using the Docker Compose Helper Script
91+
92+
For easier management of multiple compose files and image substitutions, use the `docker-composer.sh` script:
93+
94+
#### Basic Usage
95+
96+
```shell
97+
# Generate a composed configuration for development
98+
./scripts/docker-composer.sh --dev -o dev-compose.yml
99+
100+
# Generate a composed configuration for production
101+
./scripts/docker-composer.sh --prod -o prod-compose.yml
102+
103+
# Include specific model configurations
104+
./scripts/docker-composer.sh --prod \
105+
-f docker-compose.llama-3b-gpu.yml \
106+
-f docker-compose.llama-8b-gpu.yml \
107+
-o production-compose.yml
108+
```
109+
110+
#### Image Substitution
111+
112+
Replace default images with custom ones (useful for production deployments with specific image versions):
113+
114+
```shell
115+
# Production example with custom ECR images
116+
./scripts/docker-composer.sh --prod \
117+
-f docker-compose.llama-3b-gpu.yml \
118+
--image 'nillion/nilai-api:latest=public.ecr.aws/k5d9x2g2/nilai-api:v0.1.0-rc1' \
119+
--image 'nillion/nilai-vllm:latest=public.ecr.aws/k5d9x2g2/nilai-vllm:v0.1.0-rc1' \
120+
--image 'nillion/nilai-attestation:latest=public.ecr.aws/k5d9x2g2/nilai-attestation:v0.1.0-rc1' \
121+
-o production-compose.yml
122+
123+
# Then deploy with the generated file
124+
docker compose -f production-compose.yml up -d
125+
```
126+
127+
#### Script Options
128+
129+
- `--dev`: Include development-specific configurations
130+
- `--prod`: Include production-specific configurations
131+
- `-f, --file <filename>`: Include additional compose files from `docker/compose/` directory
132+
- `-o, --output <filename>`: Specify output filename (default: `output.yml`)
133+
- `--image <old=new>`: Substitute Docker images (can be used multiple times)
134+
- `-h, --help`: Show help message
135+
136+
#### Production Deployment Example
137+
138+
For a complete production setup with custom images:
139+
140+
```shell
141+
# 1. Generate the production compose file
142+
./scripts/docker-composer.sh --prod \
143+
-f docker/compose/docker-compose.llama-3b-gpu.yml \
144+
-f docker/compose/docker-compose.llama-8b-gpu.yml \
145+
--image 'nillion/nilai-api:latest=public.ecr.aws/k5d9x2g2/nilai-api:v0.2.0-alpha-0' \
146+
--image 'nillion/nilai-vllm:latest=public.ecr.aws/k5d9x2g2/nilai-vllm:v0.2.0-alpha-0' \
147+
--image 'nillion/nilai-attestation:latest=public.ecr.aws/k5d9x2g2/nilai-attestation:v0.2.0-alpha-0' \
148+
-o production-compose.yml
149+
150+
# Or:
151+
./scripts/docker-composer.sh --prod \
152+
-f docker/compose/docker-compose.llama-70b-gpu.yml \
153+
--image 'nillion/nilai-api:latest=jcabrero/nillion-nilai-api:latest' \
154+
--image 'nillion/nilai-vllm:latest=public.ecr.aws/k5d9x2g2/nilai-vllm:v0.1.0-rc1' \
155+
--image 'nillion/nilai-attestation:latest=public.ecr.aws/k5d9x2g2/nilai-attestation:v0.1.0-rc1' \
156+
-o production-compose.yml
157+
158+
159+
# 2. Deploy using the generated file
160+
docker compose -f production-compose.yml up -d
161+
162+
# 3. Monitor logs
163+
docker compose -f production-compose.yml logs -f
164+
```
165+
166+
### 3. Manual Component Deployment
91167

92168
#### Components
93169

caddy/Caddyfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
uri strip_prefix /nuc
1717
reverse_proxy nuc-api:8080
1818
}
19+
1920
handle_path /prod/nuc/* {
2021
uri strip_prefix /prod/nuc
2122
reverse_proxy prod-nilai-nuc-api:8080

caddy/Caddyfile.http

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Disable automatic HTTPS and use HTTP only
2+
{
3+
auto_https off
4+
default_bind 0.0.0.0
5+
}
6+
7+
# Use :80 explicitly to force HTTP-only behavior
8+
:80 {
9+
handle_path /grafana/* {
10+
uri strip_prefix /grafana
11+
reverse_proxy grafana:3000
12+
}
13+
14+
handle_path /nuc/* {
15+
uri strip_prefix /nuc
16+
reverse_proxy nuc-api:8080
17+
}
18+
19+
handle_path /prod/nuc/* {
20+
uri strip_prefix /prod/nuc
21+
reverse_proxy prod-nilai-nuc-api:8080
22+
}
23+
24+
handle_path /prod/grafana/* {
25+
uri strip_prefix /prod/grafana
26+
reverse_proxy prod-grafana:3000
27+
}
28+
29+
handle_path /prod/* {
30+
uri strip_prefix /prod/base
31+
reverse_proxy prod-nilai-api:8080
32+
}
33+
34+
handle {
35+
reverse_proxy api:8080
36+
}
37+
}

docker-compose.dev.yml

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,99 @@
11
services:
2+
caddy:
3+
env_file:
4+
- .env
5+
ports:
6+
- "80:80"
7+
- "443:443"
8+
- "443:443/udp"
9+
volumes:
10+
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
211
api:
312
platform: linux/amd64 # for macOS to force running on Rosetta 2
413
ports:
514
- "8080:8080"
15+
env_file:
16+
- .env
617
volumes:
718
- ./nilai-api/:/app/nilai-api/
819
- ./packages/:/app/packages/
920
- ./nilai-auth/nuc-helpers/:/app/nilai-auth/nuc-helpers/
10-
networks:
11-
- nilauth
1221
nuc-api:
1322
platform: linux/amd64 # for macOS to force running on Rosetta 2
1423
ports:
1524
- "8088:8080"
25+
env_file:
26+
- .env
1627
volumes:
1728
- ./nilai-api/:/app/nilai-api/
1829
- ./packages/:/app/packages/
1930
- ./nilai-auth/nuc-helpers/:/app/nilai-auth/nuc-helpers/
20-
networks:
21-
- nilauth
2231
attestation:
2332
ports:
2433
- "8081:8080"
34+
env_file:
35+
- .env
2536
volumes:
2637
- ./nilai-attestation/:/app/nilai-attestation/
2738
- ./packages/:/app/packages/
2839
redis:
2940
ports:
3041
- "6379:6379"
3142
postgres:
43+
image: postgres:16
44+
container_name: postgres
45+
restart: always
3246
ports:
3347
- "5432:5432"
48+
env_file:
49+
- .env
50+
volumes:
51+
- postgres_data:/var/lib/postgresql/data
52+
healthcheck:
53+
test: ["CMD", "sh", "-c", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB} -h localhost"]
54+
interval: 30s
55+
retries: 5
56+
start_period: 10s
57+
timeout: 10s
58+
3459
nuc-postgres:
60+
image: postgres:16
61+
container_name: nuc-postgres
62+
restart: always
63+
environment:
64+
- POSTGRES_HOST=nuc-postgres
3565
ports:
3666
- "5433:5432"
67+
env_file:
68+
- .env
69+
volumes:
70+
- nuc_postgres_data:/var/lib/postgresql/data
71+
healthcheck:
72+
test: ["CMD", "sh", "-c", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB} -h localhost"]
73+
interval: 30s
74+
retries: 5
75+
start_period: 10s
76+
timeout: 10s
3777
grafana:
78+
env_file:
79+
- .env
3880
ports:
3981
- "3000:3000"
40-
82+
volumes:
83+
- ${PWD}/grafana/runtime-data:/var/lib/grafana
84+
- ${PWD}/grafana/datasources/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml
85+
- ${PWD}/grafana/dashboards/filesystem.yml:/etc/grafana/provisioning/dashboards/filesystem.yml
86+
- ${PWD}/grafana/config/grafana.ini:/etc/grafana/grafana.ini
87+
prometheus:
88+
volumes:
89+
- ${PWD}/prometheus/config/prometheus.yml:/etc/prometheus/prometheus.yml
90+
- ${PWD}/prometheus/data:/prometheus/data
4191
nilauth-postgres:
4292
image: postgres:17
4393
environment:
4494
POSTGRES_PASSWORD: postgres
4595
ports:
4696
- "30432:5432"
47-
networks:
48-
- nilauth
4997

5098
nilchain:
5199
image: ghcr.io/nillionnetwork/nilchain-devnet:v0.1.0
@@ -55,8 +103,6 @@ services:
55103
- "26648:26648" # JSON RPC
56104
- "26649:26649" # gRPC
57105
- "26650:26650" # REST
58-
networks:
59-
- nilauth
60106

61107
nilauth:
62108
image: public.ecr.aws/k5d9x2g2/nilauth:ff0d9198d1b8819527bc036a58f875c4046b6f21
@@ -69,17 +115,15 @@ services:
69115
ports:
70116
- "30921:30921" # main server
71117
- "30922:30022" # metrics server
72-
networks:
73-
- nilauth
74118

75119
token-price-api:
76120
image: caddy:2
77121
ports:
78122
- "30923:80"
79123
command: |
80124
caddy respond --listen :80 --body '{"nillion":{"usd":1}}' --header "Content-Type: application/json"
81-
networks:
82-
- nilauth
83125
84-
networks:
85-
nilauth:
126+
127+
volumes:
128+
postgres_data:
129+
nuc_postgres_data:

docker-compose.prod.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
services:
2+
prometheus:
3+
volumes:
4+
- ./files/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
5+
- prometheus_data:/prometheus/data
6+
grafana:
7+
env_file:
8+
- .env.mainnet
9+
volumes:
10+
- ./files/grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml
11+
- ./files/grafana/filesystem.yml:/etc/grafana/provisioning/dashboards/filesystem.yml
12+
- ./files/grafana/grafana.ini:/etc/grafana/grafana.ini
13+
- ./files/grafana/nuc-query-data.json:/var/lib/grafana/dashboards/nuc-query-data.json
14+
- ./files/grafana/query-data.json:/var/lib/grafana/dashboards/query-data.json
15+
api:
16+
env_file:
17+
- .env.mainnet
18+
volumes:
19+
- ./files/nilai-api/config.yaml:/app/nilai-api/src/nilai_api/config/config.yaml
20+
nuc-api:
21+
env_file:
22+
- .env.mainnet
23+
environment:
24+
- POSTGRES_DB="nuc-nilai-mainnet2"
25+
volumes:
26+
- ./files/nilai-api/config.yaml:/app/nilai-api/src/nilai_api/config/config.yaml
27+
caddy:
28+
env_file:
29+
- .env.mainnet
30+
volumes:
31+
- ./files/caddy/caddyfile:/etc/caddy/Caddyfile
232
attestation:
333
deploy:
434
resources:

0 commit comments

Comments
 (0)