File size: 6,509 Bytes
9853396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# Docker Deployment

## Overview

This guide covers deploying AxonHub using Docker and Docker Compose. Docker provides an isolated, reproducible environment that simplifies deployment and scaling.

## Quick Start

### 1. Clone the Repository

```bash

git clone https://github.com/looplj/axonhub.git

cd axonhub

```

### 2. Configure Environment

Copy the example configuration file:

```bash

cp config.example.yml config.yml

```

Edit `config.yml` with your settings:

```yaml

# config.yml

server:

  port: 8090

  name: "AxonHub"



db:

  dialect: "sqlite3"

  dsn: "file:axonhub.db?cache=shared&_fk=1"



log:

  level: "info"

  encoding: "json"

```

### 3. Start Services

```bash

docker-compose up -d

```

### 4. Verify Deployment

Check service status:

```bash

docker-compose ps

```

Access the application:
- Web interface: http://localhost:8090
- Default admin: admin@example.com / admin123

## Docker Compose Configuration

### Basic docker-compose.yml

```yaml

version: '3.8'



services:

  axonhub:

    image: looplj/axonhub:latest

    ports:

      - "8090:8090"

    volumes:

      - ./config.yml:/app/config.yml

      - axonhub_data:/app/data

    environment:

      - AXONHUB_SERVER_PORT=8090

      - AXONHUB_DB_DIALECT=sqlite3

      - AXONHUB_DB_DSN=file:axonhub.db?cache=shared&_fk=1

    restart: unless-stopped



volumes:

  axonhub_data:

```

### Production Configuration

```yaml

version: '3.8'



services:

  axonhub:

    image: looplj/axonhub:latest

    ports:

      - "8090:8090"

    volumes:

      - ./config.yml:/app/config.yml

      - axonhub_data:/app/data

      - ./logs:/app/logs

    environment:

      - AXONHUB_SERVER_PORT=8090

      - AXONHUB_DB_DIALECT=postgres

      - AXONHUB_DB_DSN=postgres://axonhub:password@postgres:5432/axonhub

      - AXONHUB_LOG_LEVEL=warn

      - AXONHUB_LOG_OUTPUT=file

      - AXONHUB_LOG_FILE_PATH=/app/logs/axonhub.log

    depends_on:

      - postgres

    restart: unless-stopped



  postgres:

    image: postgres:15

    environment:

      - POSTGRES_DB=axonhub

      - POSTGRES_USER=axonhub

      - POSTGRES_PASSWORD=password

    volumes:

      - postgres_data:/var/lib/postgresql/data

    restart: unless-stopped



volumes:

  axonhub_data:

  postgres_data:

```

## Database Options

### SQLite (Development)

```yaml

axonhub:

  environment:

    - AXONHUB_DB_DIALECT=sqlite3

    - AXONHUB_DB_DSN=file:axonhub.db?cache=shared&_fk=1

```

### PostgreSQL (Production)

```yaml

axonhub:

  environment:

    - AXONHUB_DB_DIALECT=postgres

    - AXONHUB_DB_DSN=postgres://user:pass@host:5432/axonhub

```

### MySQL (Production)

```yaml

axonhub:

  environment:

    - AXONHUB_DB_DIALECT=mysql

    - AXONHUB_DB_DSN=user:pass@tcp(host:3306)/axonhub?charset=utf8mb4&parseTime=True

```

## Environment Variables

### Server Configuration

```bash

AXONHUB_SERVER_PORT=8090

AXONHUB_SERVER_NAME="AxonHub"

AXONHUB_SERVER_DEBUG=false

AXONHUB_SERVER_REQUEST_TIMEOUT="30s"

AXONHUB_SERVER_LLM_REQUEST_TIMEOUT="600s"

```

### Database Configuration

```bash

AXONHUB_DB_DIALECT="postgres"

AXONHUB_DB_DSN="postgres://user:pass@host:5432/axonhub"

AXONHUB_DB_DEBUG=false

```

### Logging Configuration

```bash

AXONHUB_LOG_LEVEL="info"

AXONHUB_LOG_ENCODING="json"

AXONHUB_LOG_OUTPUT="stdio"

```

## Security Considerations

### Network Security

```yaml

axonhub:

  networks:

    - axonhub_network

  ports:

    - "127.0.0.1:8090:8090"  # Bind to localhost only



networks:

  axonhub_network:

    driver: bridge

```

### Secrets Management

Use Docker secrets or environment files:

```bash

# .env file

DB_PASSWORD=your-secure-password

API_KEY_SECRET=your-api-key-secret

```

```yaml

axonhub:

  env_file:

    - .env

```

## Monitoring and Logging

### Health Checks

```yaml

axonhub:

  healthcheck:

    test: ["CMD", "curl", "-f", "http://localhost:8090/health"]

    interval: 30s

    timeout: 10s

    retries: 3

    start_period: 40s

```

### Log Collection

```yaml

axonhub:

  logging:

    driver: "json-file"

    options:

      max-size: "10m"

      max-file: "3"

```

## Scaling

### Horizontal Scaling

```yaml

axonhub:

  deploy:

    replicas: 3

    resources:

      limits:

        memory: 1G

        cpus: '0.5'

      reservations:

        memory: 512M

        cpus: '0.25'

```

### Load Balancer Setup

```yaml

services:

  axonhub:

    image: looplj/axonhub:latest

    deploy:

      replicas: 3

    networks:

      - axonhub_network



  nginx:

    image: nginx:alpine

    ports:

      - "80:80"

    volumes:

      - ./nginx.conf:/etc/nginx/nginx.conf

    depends_on:

      - axonhub

    networks:

      - axonhub_network

```

## Backup and Recovery

### Database Backup

```yaml

services:

  backup:

    image: postgres:15

    volumes:

      - ./backup:/backup

      - postgres_data:/var/lib/postgresql/data

    command: |

      bash -c '

        pg_dump -h postgres -U axonhub axonhub > /backup/axonhub-$(date +%Y%m%d).sql

      '

    depends_on:

      - postgres

    environment:

      - PGPASSWORD=password

```

### Volume Backup

```bash

# Backup data volume

docker run --rm -v axonhub_data:/source -v $(pwd)/backup:/backup alpine \

  tar czf /backup/axonhub-data-$(date +%Y%m%d).tar.gz -C /source .



# Restore data volume

docker run --rm -v axonhub_data:/target -v $(pwd)/backup:/backup alpine \

  tar xzf /backup/axonhub-data-20231110.tar.gz -C /target

```

## Troubleshooting

### Common Issues

**Container fails to start**
- Check Docker logs: `docker-compose logs axonhub`
- Verify configuration file permissions
- Ensure database connection is working

**Port conflicts**
- Change the exposed port in docker-compose.yml
- Check if another service is using port 8090

**Database connection issues**
- Verify database credentials
- Check network connectivity between containers
- Ensure database container is running

### Debug Mode

Enable debug logging for troubleshooting:

```yaml

axonhub:

  environment:

    - AXONHUB_SERVER_DEBUG=true

    - AXONHUB_LOG_LEVEL=debug

```

## Next Steps

- [Configuration Guide](configuration.md)
- [OpenAI API](../api-reference/openai-api.md)
- [Anthropic API](../api-reference/anthropic-api.md)
- [Gemini API](../api-reference/gemini-api.md)
- [Architecture Documentation](../architecture/erd.md)