compose.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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 with replicas.",
  135. "vars": {
  136. "swarm_enabled": {
  137. "description": "Enable Docker Swarm mode",
  138. "type": "bool",
  139. "default": False,
  140. },
  141. "swarm_replicas": {
  142. "description": "Number of replicas in Swarm",
  143. "type": "int",
  144. "default": 1,
  145. },
  146. "swarm_placement": {
  147. "description": "Swarm placement mode or node constraint",
  148. "type": "str",
  149. "default": "replicated",
  150. "extra": "Options: 'replicated', 'global', or 'node.hostname==myhost' for custom placement",
  151. }
  152. },
  153. },
  154. "database": {
  155. "title": "Database",
  156. "toggle": "database_enabled",
  157. "description": "Connect to external database (PostgreSQL or MySQL)",
  158. "vars": {
  159. "database_enabled": {
  160. "description": "Enable external database integration",
  161. "type": "bool",
  162. "default": False,
  163. },
  164. "database_type": {
  165. "description": "Database type",
  166. "type": "enum",
  167. "options": ["postgres", "mysql"],
  168. "default": "postgres",
  169. },
  170. "database_external": {
  171. "description": "Use an external database server?",
  172. "extra": "If 'no', a database container will be created in the compose project.",
  173. "type": "bool",
  174. "default": False,
  175. },
  176. "database_host": {
  177. "description": "Database host",
  178. "type": "str",
  179. "default": "database",
  180. },
  181. "database_port": {
  182. "description": "Database port",
  183. "type": "int"
  184. },
  185. "database_name": {
  186. "description": "Database name",
  187. "type": "str",
  188. },
  189. "database_user": {
  190. "description": "Database user",
  191. "type": "str",
  192. },
  193. "database_password": {
  194. "description": "Database password",
  195. "type": "str",
  196. "default": "",
  197. "sensitive": True,
  198. "autogenerated": True,
  199. },
  200. },
  201. },
  202. "email": {
  203. "title": "Email Server",
  204. "toggle": "email_enabled",
  205. "description": "Configure email server for notifications and user management.",
  206. "vars": {
  207. "email_enabled": {
  208. "description": "Enable email server configuration",
  209. "type": "bool",
  210. "default": False,
  211. },
  212. "email_host": {
  213. "description": "SMTP server hostname",
  214. "type": "str",
  215. },
  216. "email_port": {
  217. "description": "SMTP server port",
  218. "type": "int",
  219. "default": 587,
  220. },
  221. "email_username": {
  222. "description": "SMTP username",
  223. "type": "str",
  224. },
  225. "email_password": {
  226. "description": "SMTP password",
  227. "type": "str",
  228. "sensitive": True,
  229. },
  230. "email_from": {
  231. "description": "From email address",
  232. "type": "str",
  233. },
  234. "email_use_tls": {
  235. "description": "Use TLS encryption",
  236. "type": "bool",
  237. "default": True,
  238. },
  239. "email_use_ssl": {
  240. "description": "Use SSL encryption",
  241. "type": "bool",
  242. "default": False,
  243. }
  244. },
  245. },
  246. "authentik": {
  247. "title": "Authentik SSO",
  248. "toggle": "authentik_enabled",
  249. "description": "Integrate with Authentik for Single Sign-On authentication.",
  250. "vars": {
  251. "authentik_enabled": {
  252. "description": "Enable Authentik SSO integration",
  253. "type": "bool",
  254. "default": False,
  255. },
  256. "authentik_url": {
  257. "description": "Authentik base URL (e.g., https://auth.example.com)",
  258. "type": "str",
  259. },
  260. "authentik_slug": {
  261. "description": "Authentik application slug",
  262. "type": "str",
  263. },
  264. "authentik_client_id": {
  265. "description": "OAuth client ID from Authentik provider",
  266. "type": "str",
  267. },
  268. "authentik_client_secret": {
  269. "description": "OAuth client secret from Authentik provider",
  270. "type": "str",
  271. "sensitive": True,
  272. },
  273. },
  274. },
  275. "storage": {
  276. "title": "Storage Configuration",
  277. "toggle": "storage_enabled",
  278. "description": "Configure persistent storage volumes",
  279. "vars": {
  280. "storage_enabled": {
  281. "description": "Enable storage configuration",
  282. "type": "bool",
  283. "default": False,
  284. },
  285. "storage_mode": {
  286. "description": "Storage backend",
  287. "type": "enum",
  288. "options": ["local", "mount", "nfs", "glusterfs"],
  289. "default": "local",
  290. "extra": "local=named volume, mount=bind mount, nfs=network filesystem, glusterfs=distributed storage",
  291. },
  292. "storage_host": {
  293. "description": "Storage host/volume identifier",
  294. "type": "str",
  295. "extra": "local: volume name, mount: host path, nfs: server IP, glusterfs: server hostname",
  296. },
  297. "storage_path": {
  298. "description": "NFS export path",
  299. "type": "str",
  300. "default": "/mnt/nfs",
  301. "extra": "Only used when storage_mode=nfs",
  302. },
  303. "storage_nfs_options": {
  304. "description": "NFS mount options",
  305. "type": "str",
  306. "default": "rw,nolock,soft",
  307. "extra": "Only used when storage_mode=nfs. Comma-separated options.",
  308. },
  309. "storage_glusterfs_volume": {
  310. "description": "GlusterFS volume name",
  311. "type": "str",
  312. "default": "gv0",
  313. "extra": "Only used when storage_mode=glusterfs",
  314. },
  315. },
  316. },
  317. "config": {
  318. "title": "Config Storage",
  319. "toggle": "config_enabled",
  320. "description": "Configure persistent storage for configuration files",
  321. "vars": {
  322. "config_enabled": {
  323. "description": "Enable config storage configuration",
  324. "type": "bool",
  325. "default": False,
  326. },
  327. "config_mode": {
  328. "description": "Storage backend for configuration",
  329. "type": "enum",
  330. "options": ["local", "mount", "nfs", "glusterfs"],
  331. "default": "mount",
  332. "extra": "local=named volume, mount=bind mount, nfs=network filesystem, glusterfs=distributed storage",
  333. },
  334. "config_host": {
  335. "description": "Config storage host/volume identifier",
  336. "type": "str",
  337. "default": "./config",
  338. "extra": "local: volume name, mount: host path, nfs: server IP, glusterfs: server hostname",
  339. },
  340. "config_path": {
  341. "description": "NFS export path for config",
  342. "type": "str",
  343. "default": "/mnt/nfs/config",
  344. "extra": "Only used when config_mode=nfs",
  345. },
  346. "config_nfs_options": {
  347. "description": "NFS mount options for config",
  348. "type": "str",
  349. "default": "rw,nolock,soft",
  350. "extra": "Only used when config_mode=nfs. Comma-separated options.",
  351. },
  352. "config_glusterfs_volume": {
  353. "description": "GlusterFS volume name for config",
  354. "type": "str",
  355. "default": "gv0",
  356. "extra": "Only used when config_mode=glusterfs",
  357. },
  358. },
  359. },
  360. }
  361. )
  362. class ComposeModule(Module):
  363. """Docker Compose module."""
  364. name = "compose"
  365. description = "Manage Docker Compose configurations"
  366. schema_version = "1.1" # Current schema version supported by this module
  367. registry.register(ComposeModule)