compose.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. from collections import OrderedDict
  2. from ..core.module import Module
  3. from ..core.registry import registry
  4. spec = OrderedDict(
  5. {
  6. "general": {
  7. "title": "General",
  8. "vars": {
  9. "service_name": {
  10. "description": "Service name",
  11. "type": "str",
  12. },
  13. "container_name": {
  14. "description": "Container name",
  15. "type": "str",
  16. },
  17. "container_hostname": {
  18. "description": "Container internal hostname",
  19. "type": "str",
  20. },
  21. "container_timezone": {
  22. "description": "Container timezone (e.g., Europe/Berlin)",
  23. "type": "str",
  24. "default": "UTC",
  25. },
  26. "user_uid": {
  27. "description": "User UID for container process",
  28. "type": "int",
  29. "default": 1000,
  30. },
  31. "user_gid": {
  32. "description": "User GID for container process",
  33. "type": "int",
  34. "default": 1000,
  35. },
  36. "container_loglevel": {
  37. "description": "Container log level",
  38. "type": "enum",
  39. "options": ["debug", "info", "warn", "error"],
  40. "default": "info",
  41. },
  42. "restart_policy": {
  43. "description": "Container restart policy",
  44. "type": "enum",
  45. "options": ["unless-stopped", "always", "on-failure", "no"],
  46. "default": "unless-stopped",
  47. },
  48. },
  49. },
  50. "network": {
  51. "title": "Network",
  52. "toggle": "network_enabled",
  53. "vars": {
  54. "network_enabled": {
  55. "description": "Enable custom network block",
  56. "type": "bool",
  57. "default": False,
  58. },
  59. "network_name": {
  60. "description": "Docker network name",
  61. "type": "str",
  62. "default": "bridge",
  63. },
  64. "network_external": {
  65. "description": "Use existing Docker network",
  66. "type": "bool",
  67. "default": True,
  68. },
  69. },
  70. },
  71. "ports": {
  72. "title": "Ports",
  73. "toggle": "ports_enabled",
  74. "vars": {
  75. "ports_enabled": {
  76. "description": "Expose ports via 'ports' mapping",
  77. "type": "bool",
  78. "default": True,
  79. }
  80. },
  81. },
  82. "traefik": {
  83. "title": "Traefik",
  84. "toggle": "traefik_enabled",
  85. "description": "Traefik routes external traffic to your service.",
  86. "vars": {
  87. "traefik_enabled": {
  88. "description": "Enable Traefik reverse proxy integration",
  89. "type": "bool",
  90. "default": False,
  91. },
  92. "traefik_network": {
  93. "description": "Traefik network name",
  94. "type": "str",
  95. "default": "traefik",
  96. },
  97. "traefik_host": {
  98. "description": "Domain name for your service (e.g., app.example.com)",
  99. "type": "str",
  100. },
  101. "traefik_entrypoint": {
  102. "description": "HTTP entrypoint (non-TLS)",
  103. "type": "str",
  104. "default": "web",
  105. },
  106. },
  107. },
  108. "traefik_tls": {
  109. "title": "Traefik TLS/SSL",
  110. "toggle": "traefik_tls_enabled",
  111. "needs": "traefik_enabled=true",
  112. "description": "Enable HTTPS/TLS for Traefik with certificate management.",
  113. "vars": {
  114. "traefik_tls_enabled": {
  115. "description": "Enable HTTPS/TLS",
  116. "type": "bool",
  117. "default": True,
  118. },
  119. "traefik_tls_entrypoint": {
  120. "description": "TLS entrypoint",
  121. "type": "str",
  122. "default": "websecure",
  123. },
  124. "traefik_tls_certresolver": {
  125. "description": "Traefik certificate resolver name",
  126. "type": "str",
  127. "default": "cloudflare",
  128. },
  129. },
  130. },
  131. "swarm": {
  132. "title": "Docker Swarm",
  133. "toggle": "swarm_enabled",
  134. "description": "Deploy service in Docker Swarm mode.",
  135. "vars": {
  136. "swarm_enabled": {
  137. "description": "Enable Docker Swarm mode",
  138. "type": "bool",
  139. "default": False,
  140. },
  141. "swarm_placement_mode": {
  142. "description": "Swarm placement mode",
  143. "type": "enum",
  144. "options": ["replicated", "global"],
  145. "default": "replicated",
  146. "extra": "replicated=run specific number of tasks, global=run one task per node",
  147. },
  148. "swarm_replicas": {
  149. "description": "Number of replicas",
  150. "type": "int",
  151. "default": 1,
  152. "needs": "swarm_placement_mode=replicated",
  153. },
  154. "swarm_placement_host": {
  155. "description": "Target hostname for placement constraint",
  156. "type": "hostname",
  157. "needs": "swarm_placement_mode=replicated",
  158. "extra": "Constrains service to run on specific node by hostname",
  159. },
  160. },
  161. },
  162. "database": {
  163. "title": "Database",
  164. "toggle": "database_enabled",
  165. "description": "Connect to external database (PostgreSQL or MySQL)",
  166. "vars": {
  167. "database_enabled": {
  168. "description": "Enable external database integration",
  169. "type": "bool",
  170. "default": False,
  171. },
  172. "database_type": {
  173. "description": "Database type",
  174. "type": "enum",
  175. "options": ["postgres", "mysql"],
  176. "default": "postgres",
  177. },
  178. "database_external": {
  179. "description": "Use an external database server?",
  180. "extra": "If 'no', a database container will be created in the compose project.",
  181. "type": "bool",
  182. "default": False,
  183. },
  184. "database_host": {
  185. "description": "Database host",
  186. "type": "str",
  187. "default": "database",
  188. },
  189. "database_port": {
  190. "description": "Database port",
  191. "type": "int"
  192. },
  193. "database_name": {
  194. "description": "Database name",
  195. "type": "str",
  196. },
  197. "database_user": {
  198. "description": "Database user",
  199. "type": "str",
  200. },
  201. "database_password": {
  202. "description": "Database password",
  203. "type": "str",
  204. "default": "",
  205. "sensitive": True,
  206. "autogenerated": True,
  207. },
  208. },
  209. },
  210. "email": {
  211. "title": "Email Server",
  212. "toggle": "email_enabled",
  213. "description": "Configure email server for notifications and user management.",
  214. "vars": {
  215. "email_enabled": {
  216. "description": "Enable email server configuration",
  217. "type": "bool",
  218. "default": False,
  219. },
  220. "email_host": {
  221. "description": "SMTP server hostname",
  222. "type": "str",
  223. },
  224. "email_port": {
  225. "description": "SMTP server port",
  226. "type": "int",
  227. "default": 587,
  228. },
  229. "email_username": {
  230. "description": "SMTP username",
  231. "type": "str",
  232. },
  233. "email_password": {
  234. "description": "SMTP password",
  235. "type": "str",
  236. "sensitive": True,
  237. },
  238. "email_from": {
  239. "description": "From email address",
  240. "type": "str",
  241. },
  242. "email_use_tls": {
  243. "description": "Use TLS encryption",
  244. "type": "bool",
  245. "default": True,
  246. },
  247. "email_use_ssl": {
  248. "description": "Use SSL encryption",
  249. "type": "bool",
  250. "default": False,
  251. }
  252. },
  253. },
  254. "authentik": {
  255. "title": "Authentik SSO",
  256. "toggle": "authentik_enabled",
  257. "description": "Integrate with Authentik for Single Sign-On authentication.",
  258. "vars": {
  259. "authentik_enabled": {
  260. "description": "Enable Authentik SSO integration",
  261. "type": "bool",
  262. "default": False,
  263. },
  264. "authentik_url": {
  265. "description": "Authentik base URL (e.g., https://auth.example.com)",
  266. "type": "str",
  267. },
  268. "authentik_slug": {
  269. "description": "Authentik application slug",
  270. "type": "str",
  271. },
  272. "authentik_client_id": {
  273. "description": "OAuth client ID from Authentik provider",
  274. "type": "str",
  275. },
  276. "authentik_client_secret": {
  277. "description": "OAuth client secret from Authentik provider",
  278. "type": "str",
  279. "sensitive": True,
  280. },
  281. },
  282. },
  283. "storage": {
  284. "title": "Storage Configuration",
  285. "toggle": "storage_enabled",
  286. "description": "Configure persistent storage volumes",
  287. "vars": {
  288. "storage_enabled": {
  289. "description": "Enable storage configuration",
  290. "type": "bool",
  291. "default": False,
  292. },
  293. "storage_mode": {
  294. "description": "Storage backend",
  295. "type": "enum",
  296. "options": ["local", "mount", "nfs", "glusterfs"],
  297. "default": "local",
  298. "extra": "local=named volume, mount=bind mount, nfs=network filesystem, glusterfs=distributed storage",
  299. },
  300. "storage_host": {
  301. "description": "Storage host/volume identifier",
  302. "type": "str",
  303. "extra": "local: volume name, mount: host path, nfs: server IP, glusterfs: server hostname",
  304. },
  305. "storage_path": {
  306. "description": "NFS export path",
  307. "type": "str",
  308. "default": "/mnt/nfs",
  309. "extra": "Only used when storage_mode=nfs",
  310. },
  311. "storage_nfs_options": {
  312. "description": "NFS mount options",
  313. "type": "str",
  314. "default": "rw,nolock,soft",
  315. "extra": "Only used when storage_mode=nfs. Comma-separated options.",
  316. },
  317. "storage_glusterfs_volume": {
  318. "description": "GlusterFS volume name",
  319. "type": "str",
  320. "default": "gv0",
  321. "extra": "Only used when storage_mode=glusterfs",
  322. },
  323. },
  324. },
  325. "config": {
  326. "title": "Config Storage",
  327. "toggle": "config_enabled",
  328. "description": "Configure persistent storage for configuration files",
  329. "vars": {
  330. "config_enabled": {
  331. "description": "Enable config storage configuration",
  332. "type": "bool",
  333. "default": False,
  334. },
  335. "config_mode": {
  336. "description": "Storage backend for configuration",
  337. "type": "enum",
  338. "options": ["local", "mount", "nfs", "glusterfs"],
  339. "default": "mount",
  340. "extra": "local=named volume, mount=bind mount, nfs=network filesystem, glusterfs=distributed storage",
  341. },
  342. "config_host": {
  343. "description": "Config storage host/volume identifier",
  344. "type": "str",
  345. "default": "./config",
  346. "extra": "local: volume name, mount: host path, nfs: server IP, glusterfs: server hostname",
  347. },
  348. "config_path": {
  349. "description": "NFS export path for config",
  350. "type": "str",
  351. "default": "/mnt/nfs/config",
  352. "extra": "Only used when config_mode=nfs",
  353. },
  354. "config_nfs_options": {
  355. "description": "NFS mount options for config",
  356. "type": "str",
  357. "default": "rw,nolock,soft",
  358. "extra": "Only used when config_mode=nfs. Comma-separated options.",
  359. },
  360. "config_glusterfs_volume": {
  361. "description": "GlusterFS volume name for config",
  362. "type": "str",
  363. "default": "gv0",
  364. "extra": "Only used when config_mode=glusterfs",
  365. },
  366. },
  367. },
  368. }
  369. )
  370. class ComposeModule(Module):
  371. """Docker Compose module."""
  372. name = "compose"
  373. description = "Manage Docker Compose configurations"
  374. schema_version = "1.1" # Current schema version supported by this module
  375. registry.register(ComposeModule)