compose.py 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from ..core.module import Module
  2. from ..core.registry import registry
  3. class ComposeModule(Module):
  4. """Docker Compose module."""
  5. name = "compose"
  6. description = "Manage Docker Compose configurations"
  7. files = ["docker-compose.yml", "docker-compose.yaml", "compose.yml", "compose.yaml"]
  8. variables_spec = {
  9. # Root
  10. "service_name": {"type": "str", "display": "Service Name", "description": "Service name"},
  11. "container_name": {"type": "str", "display": "Container Name", "description": "Custom container name (leave empty to use service name)"},
  12. "container_timezone": {"type": "str", "display": "Container Timezone", "description": "Container timezone (e.g., Europe/Berlin, America/New_York)"},
  13. "container_loglevel": {"type": "enum", "display": "Log Level", "description": "Container log level", "default": "info", "options": ["debug", "info", "warn", "error"]},
  14. "container_hostname": {"type": "str", "display": "Container Hostname", "description": "Container hostname (shows up in logs and networking)"},
  15. "restart_policy": {"type": "enum", "display": "Restart Policy", "description": "Container restart policy", "default": "unless-stopped", "options": ["unless-stopped", "always", "on-failure", "no"]},
  16. # Ports
  17. "ports": {"type": "bool", "display": "Enable Ports", "description": "Enable port mapping"},
  18. # Network
  19. "network": {"type": "bool", "display": "Enable Network", "description": "Enable custom network configuration"},
  20. "network.name": {"type": "str", "display": "Network Name", "description": "Docker network name (e.g., frontend, backend, bridge)", "default": "bridge"},
  21. "network.external": {"type": "bool", "display": "External Network", "description": "Use existing network (must be created before running)"},
  22. # Traefik
  23. "traefik": {"type": "bool", "display": "Enable Traefik", "description": "Enable Traefik reverse proxy (requires Traefik to be running separately)"},
  24. "traefik.host": {"type": "hostname", "display": "Host Domain", "description": "Domain name for your service (e.g., app.example.com)"},
  25. "traefik.entrypoint": {"type": "str", "display": "HTTP Entrypoint", "description": "HTTP entrypoint for non-TLS traffic (e.g., web, http)", "default": "web"},
  26. "traefik.tls": {"type": "bool", "display": "Enable TLS", "description": "Enable HTTPS/TLS (requires valid domain and DNS configuration)"},
  27. "traefik.tls.entrypoint": {"type": "str", "display": "TLS Entrypoint", "description": "TLS entrypoint for HTTPS traffic (e.g., websecure, https)", "default": "websecure"},
  28. "traefik.tls.certresolver": {"type": "str", "display": "Cert Resolver", "description": "Certificate resolver name (e.g., letsencrypt, staging)"},
  29. # PostgreSQL
  30. "postgres": {"type": "bool", "display": "Enable PostgreSQL", "description": "Enable PostgreSQL database"},
  31. "postgres.host": {"type": "str", "display": "PostgreSQL Host", "description": "PostgreSQL host (e.g., localhost, postgres, db.example.com)"},
  32. # Swarm
  33. "swarm": {"type": "bool", "display": "Enable Swarm", "description": "Enable Docker Swarm mode (requires Docker Swarm to be initialized)"},
  34. "swarm.replicas": {"type": "int", "display": "Replicas", "description": "Number of container instances", "default": 1},
  35. }
  36. # Register the module
  37. registry.register(ComposeModule)