CoolFace
Apppublic

hallidda/axonhub

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
docker-compose.yml173 linesDownload Raw Back to root
1# AxonHub Docker Compose Configuration
2#
3# CONFIGURATION OPTIONS:
4# 1. 环境变量 - 适用于敏感配置 (如数据库DSN、密码等),优先级高于配置文件
5#    参考: https://github.com/looplj/axonhub/blob/main/docs/deployment/configuration.md#configuration-priority
6#
7# 2. 配置文件 - 适用于复杂配置 (如缓存、日志、监控等)
8#    创建 config.yml 文件并取消 volumes 配置的注释
9#    配置参考: https://github.com/looplj/axonhub/blob/main/docs/deployment/configuration.md
10#
11# 3. 简单部署 - 如果不需要复杂配置,可以注释掉 config 的 volumes 配置
12#    仅使用环境变量进行基本配置即可运行
13
14services:
15  # PostgreSQL 数据库
16  postgres:
17    image: postgres:16-alpine
18    container_name: axonhub-postgres
19    environment:
20      POSTGRES_DB: axonhub
21      POSTGRES_USER: axonhub
22      POSTGRES_PASSWORD: ${DB_PASSWORD:-axonhub_password}
23    volumes:
24      - postgres_data:/var/lib/postgresql/data
25    ports:
26      - "5432:5432"
27    networks:
28      - axonhub-network
29    restart: unless-stopped
30    healthcheck:
31      test: ["CMD-SHELL", "pg_isready -U axonhub"]
32      interval: 10s
33      timeout: 5s
34      retries: 5
35
36  # AxonHub 主服务
37  axonhub:
38    image: looplj/axonhub:latest
39    container_name: axonhub-app
40    environment:
41      # 数据库配置可以通过环境变量设置,优先级高于配置文件
42      AXONHUB_DB_DIALECT: postgres
43      AXONHUB_DB_DSN: postgres://axonhub:${DB_PASSWORD:-axonhub_password}@postgres:5432/axonhub?sslmode=disable
44    ports:
45      - "8090:8090"
46    volumes:
47      # 配置文件挂载 - 用于复杂配置,如缓存、日志、监控等
48      # 参考: https://github.com/looplj/axonhub/blob/main/docs/deployment/configuration.md
49      - ./config.yml:/app/config.yml:ro
50      # - axonhub_data:/data
51    networks:
52      - axonhub-network
53    depends_on:
54      postgres:
55        condition: service_healthy
56    restart: unless-stopped
57    healthcheck:
58      test:
59        [
60          "CMD",
61          "wget",
62          "--no-verbose",
63          "--tries=1",
64          "--spider",
65          "http://localhost:8090/health",
66        ]
67      interval: 30s
68      timeout: 10s
69      retries: 3
70      start_period: 40s
71
72  # SQLite 配置示例 (取消注释以使用 SQLite)
73  # 注意: 此服务与上面的 'axonhub' 服务冲突。请只启用其中一个。
74  # 先执行 
75  # mkdir data
76  # chmod 777 data
77  # axonhub-sqlite:
78  #   image: looplj/axonhub:latest
79  #   container_name: axonhub-sqlite-app
80  #   environment:
81  #     AXONHUB_DB_DIALECT: sqlite3
82  #     AXONHUB_DB_DSN: file:/data/axonhub.db?cache=shared&_fk=1
83  #   ports:
84  #     - "8090:8090"
85  #   volumes:
86  #     # 配置文件挂载 - 用于复杂配置
87  #     # 参考: https://github.com/looplj/axonhub/blob/main/docs/deployment/configuration.md
88  #     - ./config.yml:/app/config.yml:ro
89  #     - ./data:/data
90  #   restart: unless-stopped
91  #   healthcheck:
92  #     test:
93  #       [
94  #         "CMD",
95  #         "wget",
96  #         "--no-verbose",
97  #         "--tries=1",
98  #         "--spider",
99  #         "http://localhost:8090/health",
100  #       ]
101  #     interval: 30s
102  #     timeout: 10s
103  #     retries: 3
104  #     start_period: 40s
105
106  # MySQL 配置示例 (取消注释以使用 MySQL)
107  # 注意: 此服务与上面的 'axonhub' 服务冲突。请只启用其中一个。
108  # mysql:
109  #   image: mysql:8.0
110  #   container_name: axonhub-mysql
111  #   environment:
112  #     MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-axonhub_root_password}
113  #     MYSQL_DATABASE: axonhub
114  #     MYSQL_USER: axonhub
115  #     MYSQL_PASSWORD: ${MYSQL_PASSWORD:-axonhub_password}
116  #   volumes:
117  #     - mysql_data:/var/lib/mysql
118  #   ports:
119  #     - "3306:3306"
120  #   networks:
121  #     - axonhub-network
122  #   restart: unless-stopped
123  #   healthcheck:
124  #     test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-axonhub_root_password}"]
125  #     interval: 10s
126  #     timeout: 5s
127  #     retries: 5
128  #
129  # # AxonHub 主服务 (MySQL 版本)
130  # # 注意: 取消注释此服务时,请注释掉上面的 PostgreSQL 版本 axonhub 服务
131  # axonhub-mysql:
132  #   image: looplj/axonhub:latest
133  #   container_name: axonhub-mysql-app
134  #   environment:
135  #     AXONHUB_DB_DIALECT: mysql
136  #     # DSN 格式参考: ${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(mysql:3306)/${MYSQL_DATABASE}?charset=utf8mb4&parseTime=True&loc=Local
137  #     AXONHUB_DB_DSN: axonhub:${MYSQL_PASSWORD:-axonhub_password}@tcp(mysql:3306)/axonhub?charset=utf8mb4&parseTime=True&loc=Local
138  #   ports:
139  #     - "8090:8090"
140  #   volumes:
141  #     # 配置文件挂载 - 用于复杂配置
142  #     # 参考: https://github.com/looplj/axonhub/blob/main/docs/deployment/configuration.md
143  #     - ./config.yml:/app/config.yml:ro
144  #     # - axonhub_data:/data
145  #   networks:
146  #     - axonhub-network
147  #   depends_on:
148  #     mysql:
149  #       condition: service_healthy
150  #   restart: unless-stopped
151  #   healthcheck:
152  #     test:
153  #       [
154  #         "CMD",
155  #         "wget",
156  #         "--no-verbose",
157  #         "--tries=1",
158  #         "--spider",
159  #         "http://localhost:8090/health",
160  #       ]
161  #     interval: 30s
162  #     timeout: 10s
163  #     retries: 3
164  #     start_period: 40s
165
166volumes:
167  postgres_data:
168  mysql_data:
169
170networks:
171  axonhub-network:
172    driver: bridge
173