compose.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. from collections import OrderedDict
  2. from ..core.module import Module
  3. from ..core.registry import registry
  4. class ComposeModule(Module):
  5. """Docker Compose module."""
  6. name = "compose"
  7. description = "Manage Docker Compose configurations"
  8. files = ["compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"]
  9. variable_sections = OrderedDict(
  10. {
  11. "general": {
  12. "title": "General",
  13. "vars": {
  14. "service_name": {
  15. "description": "Service name",
  16. "type": "str",
  17. "default": "",
  18. },
  19. "container_name": {
  20. "description": "Container name",
  21. "type": "str",
  22. "default": "",
  23. },
  24. "container_timezone": {
  25. "description": "Container timezone (e.g., Europe/Berlin)",
  26. "type": "str",
  27. "default": "UTC",
  28. },
  29. "container_loglevel": {
  30. "description": "Container log level",
  31. "type": "enum",
  32. "options": ["debug", "info", "warn", "error"],
  33. "default": "info",
  34. },
  35. "restart_policy": {
  36. "description": "Container restart policy",
  37. "type": "enum",
  38. "options": ["unless-stopped", "always", "on-failure", "no"],
  39. "default": "unless-stopped",
  40. },
  41. },
  42. },
  43. "network": {
  44. "title": "Network",
  45. "prompt": "Enable custom network block?",
  46. "toggle": "network_enabled",
  47. "vars": {
  48. "network_enabled": {
  49. "description": "Enable custom network block",
  50. "type": "bool",
  51. "default": False,
  52. },
  53. "network_name": {
  54. "description": "Docker network name",
  55. "type": "str",
  56. "default": "bridge",
  57. },
  58. "network_external": {
  59. "description": "Use existing Docker network",
  60. "type": "bool",
  61. "default": True,
  62. },
  63. },
  64. },
  65. "ports": {
  66. "title": "Ports",
  67. "prompt": "Expose ports via 'ports' mapping?",
  68. "toggle": "ports_enabled",
  69. "vars": {
  70. "ports_enabled": {
  71. "description": "Expose ports via 'ports' mapping",
  72. "type": "bool",
  73. "default": False,
  74. },
  75. "service_port_http": {
  76. "description": "HTTP service port (host)",
  77. "type": "int",
  78. "default": 8080,
  79. },
  80. "service_port_https": {
  81. "description": "HTTPS service port (host)",
  82. "type": "int",
  83. "default": 8443,
  84. },
  85. "ports_http": {
  86. "description": "Port for HTTP access to the service",
  87. "type": "int",
  88. "default": 5678,
  89. },
  90. },
  91. },
  92. "traefik": {
  93. "title": "Traefik",
  94. "prompt": "Enable Traefik reverse proxy integration?",
  95. "toggle": "traefik_enabled",
  96. "description": "Traefik routes external traffic to your service.",
  97. "vars": {
  98. "traefik_enabled": {
  99. "description": "Enable Traefik reverse proxy integration",
  100. "type": "bool",
  101. "default": False,
  102. },
  103. "traefik_host": {
  104. "description": "Domain name for your service",
  105. "type": "hostname",
  106. "default": "",
  107. },
  108. "traefik_entrypoint": {
  109. "description": "HTTP entrypoint (non-TLS)",
  110. "type": "str",
  111. "default": "web",
  112. },
  113. "traefik_tls_enabled": {
  114. "description": "Enable HTTPS/TLS",
  115. "type": "bool",
  116. "default": True,
  117. },
  118. "traefik_tls_entrypoint": {
  119. "description": "TLS entrypoint",
  120. "type": "str",
  121. "default": "websecure",
  122. },
  123. "traefik_tls_certresolver": {
  124. "description": "Traefik certificate resolver name",
  125. "type": "str",
  126. "default": "",
  127. },
  128. },
  129. },
  130. "swarm": {
  131. "title": "Docker Swarm",
  132. "vars": {
  133. "swarm_enabled": {
  134. "description": "Enable Docker Swarm mode",
  135. "type": "bool",
  136. "default": False,
  137. },
  138. "swarm_replicas": {
  139. "description": "Number of replicas in Swarm",
  140. "type": "int",
  141. "default": 1,
  142. },
  143. },
  144. },
  145. "nginx": {
  146. "title": "Nginx Dashboard",
  147. "vars": {
  148. "nginx_dashboard_enabled": {
  149. "description": "Enable Nginx dashboard",
  150. "type": "bool",
  151. "default": False,
  152. },
  153. "nginx_dashboard_port": {
  154. "description": "Nginx dashboard port (host)",
  155. "type": "int",
  156. "default": 8081,
  157. },
  158. },
  159. },
  160. "postgres": {
  161. "title": "PostgreSQL",
  162. "prompt": "Configure external PostgreSQL database?",
  163. "toggle": "postgres_enabled",
  164. "vars": {
  165. "postgres_enabled": {
  166. "description": "Enable PostgreSQL integration",
  167. "type": "bool",
  168. "default": False,
  169. },
  170. "postgres_host": {
  171. "description": "PostgreSQL host",
  172. "type": "str",
  173. "default": "postgres",
  174. },
  175. "postgres_port": {
  176. "description": "PostgreSQL port",
  177. "type": "int",
  178. "default": 5432,
  179. },
  180. "postgres_database": {
  181. "description": "PostgreSQL database name",
  182. "type": "str",
  183. "default": "",
  184. },
  185. "postgres_user": {
  186. "description": "PostgreSQL user",
  187. "type": "str",
  188. "default": "",
  189. },
  190. "postgres_password": {
  191. "description": "PostgreSQL password",
  192. "type": "str",
  193. "default": "",
  194. },
  195. },
  196. },
  197. }
  198. )
  199. registry.register(ComposeModule)