compose.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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": "str",
  157. "default": "",
  158. "optional": True,
  159. "needs": "swarm_placement_mode=replicated",
  160. "extra": "Constrains service to run on specific node by hostname (optional)",
  161. },
  162. "swarm_volume_mode": {
  163. "description": "Swarm volume storage backend",
  164. "type": "enum",
  165. "options": ["local", "mount", "nfs"],
  166. "default": "local",
  167. "extra": "WARNING: 'local' only works on single-node deployments!",
  168. },
  169. "swarm_volume_mount_path": {
  170. "description": "Host path for bind mount",
  171. "type": "str",
  172. "default": "/mnt/storage",
  173. "needs": "swarm_volume_mode=mount",
  174. "extra": "Useful for shared/replicated storage",
  175. },
  176. "swarm_volume_nfs_server": {
  177. "description": "NFS server address",
  178. "type": "str",
  179. "default": "192.168.1.1",
  180. "needs": "swarm_volume_mode=nfs",
  181. "extra": "IP address or hostname of NFS server",
  182. },
  183. "swarm_volume_nfs_path": {
  184. "description": "NFS export path",
  185. "type": "str",
  186. "default": "/export",
  187. "needs": "swarm_volume_mode=nfs",
  188. "extra": "Path to NFS export on the server",
  189. },
  190. "swarm_volume_nfs_options": {
  191. "description": "NFS mount options",
  192. "type": "str",
  193. "default": "rw,nolock,soft",
  194. "needs": "swarm_volume_mode=nfs",
  195. "extra": "Comma-separated NFS mount options",
  196. },
  197. },
  198. },
  199. "database": {
  200. "title": "Database",
  201. "toggle": "database_enabled",
  202. "description": "Connect to external database (PostgreSQL or MySQL)",
  203. "vars": {
  204. "database_enabled": {
  205. "description": "Enable external database integration",
  206. "type": "bool",
  207. "default": False,
  208. },
  209. "database_type": {
  210. "description": "Database type",
  211. "type": "enum",
  212. "options": ["postgres", "mysql"],
  213. "default": "postgres",
  214. },
  215. "database_external": {
  216. "description": "Use an external database server?",
  217. "extra": "If 'no', a database container will be created in the compose project.",
  218. "type": "bool",
  219. "default": False,
  220. },
  221. "database_host": {
  222. "description": "Database host",
  223. "type": "str",
  224. "default": "database",
  225. },
  226. "database_port": {
  227. "description": "Database port",
  228. "type": "int"
  229. },
  230. "database_name": {
  231. "description": "Database name",
  232. "type": "str",
  233. },
  234. "database_user": {
  235. "description": "Database user",
  236. "type": "str",
  237. },
  238. "database_password": {
  239. "description": "Database password",
  240. "type": "str",
  241. "default": "",
  242. "sensitive": True,
  243. "autogenerated": True,
  244. },
  245. },
  246. },
  247. "email": {
  248. "title": "Email Server",
  249. "toggle": "email_enabled",
  250. "description": "Configure email server for notifications and user management.",
  251. "vars": {
  252. "email_enabled": {
  253. "description": "Enable email server configuration",
  254. "type": "bool",
  255. "default": False,
  256. },
  257. "email_host": {
  258. "description": "SMTP server hostname",
  259. "type": "str",
  260. },
  261. "email_port": {
  262. "description": "SMTP server port",
  263. "type": "int",
  264. "default": 587,
  265. },
  266. "email_username": {
  267. "description": "SMTP username",
  268. "type": "str",
  269. },
  270. "email_password": {
  271. "description": "SMTP password",
  272. "type": "str",
  273. "sensitive": True,
  274. },
  275. "email_from": {
  276. "description": "From email address",
  277. "type": "str",
  278. },
  279. "email_use_tls": {
  280. "description": "Use TLS encryption",
  281. "type": "bool",
  282. "default": True,
  283. },
  284. "email_use_ssl": {
  285. "description": "Use SSL encryption",
  286. "type": "bool",
  287. "default": False,
  288. }
  289. },
  290. },
  291. "authentik": {
  292. "title": "Authentik SSO",
  293. "toggle": "authentik_enabled",
  294. "description": "Integrate with Authentik for Single Sign-On authentication.",
  295. "vars": {
  296. "authentik_enabled": {
  297. "description": "Enable Authentik SSO integration",
  298. "type": "bool",
  299. "default": False,
  300. },
  301. "authentik_url": {
  302. "description": "Authentik base URL (e.g., https://auth.example.com)",
  303. "type": "str",
  304. },
  305. "authentik_slug": {
  306. "description": "Authentik application slug",
  307. "type": "str",
  308. },
  309. "authentik_client_id": {
  310. "description": "OAuth client ID from Authentik provider",
  311. "type": "str",
  312. },
  313. "authentik_client_secret": {
  314. "description": "OAuth client secret from Authentik provider",
  315. "type": "str",
  316. "sensitive": True,
  317. },
  318. },
  319. }
  320. }
  321. )
  322. class ComposeModule(Module):
  323. """Docker Compose module."""
  324. name = "compose"
  325. description = "Manage Docker Compose configurations"
  326. schema_version = "1.1" # Current schema version supported by this module
  327. registry.register(ComposeModule)