compose.yaml.j2 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. services:
  2. {{ service_name }}:
  3. image: ghcr.io/gethomepage/homepage:v1.6.1
  4. {#
  5. If not in swarm mode, check whether container_name is set and apply restart policy,
  6. else swarm mode handles restarts via deploy.restart_policy
  7. #}
  8. {% if not swarm_enabled %}
  9. restart: {{ restart_policy }}
  10. container_name: {{ container_name }}
  11. {% endif %}
  12. {#
  13. Set container hostname for identification
  14. #}
  15. hostname: {{ container_hostname }}
  16. {#
  17. Environment variables for Homepage configuration:
  18. - Timezone, log level, and allowed hosts
  19. - Optional user/group IDs for file permissions
  20. #}
  21. environment:
  22. - TZ={{ container_timezone }}
  23. - LOG_LEVEL={{ container_loglevel }}
  24. - HOMEPAGE_ALLOWED_HOSTS={{ homepage_allowed_hosts }}
  25. {% if homepage_puid %}
  26. - PUID={{ homepage_puid }}
  27. - PGID={{ homepage_pgid }}
  28. {% endif %}
  29. {#
  30. When traefik is enabled, add traefik network for reverse proxy access
  31. #}
  32. {% if traefik_enabled %}
  33. networks:
  34. {{ traefik_network }}:
  35. {% endif %}
  36. {#
  37. Port mappings for web interface (only when Traefik is disabled)
  38. #}
  39. {% if not traefik_enabled %}
  40. ports:
  41. - {{ ports_http }}:3000
  42. {% endif %}
  43. {#
  44. Volume configuration for persistent data:
  45. - config: Dashboard configuration files
  46. - images: Custom images for dashboard
  47. - icons: Custom icons for services
  48. #}
  49. volumes:
  50. {% if volume_mode == 'local' %}
  51. - {{ service_name }}_config:/app/config
  52. - {{ service_name }}_images:/app/images
  53. - {{ service_name }}_icons:/app/icons
  54. {% elif volume_mode == 'mount' %}
  55. - {{ volume_mount_path }}/{{ service_name }}/config:/app/config
  56. - {{ volume_mount_path }}/{{ service_name }}/images:/app/images
  57. - {{ volume_mount_path }}/{{ service_name }}/icons:/app/icons
  58. {% endif %}
  59. {#
  60. When traefik_enabled is set, and not running in swarm mode, add traefik labels
  61. (optionally enable TLS if traefik_tls_enabled is set)
  62. #}
  63. {% if traefik_enabled and not swarm_enabled %}
  64. labels:
  65. - traefik.enable=true
  66. - traefik.docker.network={{ traefik_network }}
  67. - traefik.http.services.{{ service_name }}-web.loadbalancer.server.port=3000
  68. - traefik.http.routers.{{ service_name }}-http.service={{ service_name }}-web
  69. - traefik.http.routers.{{ service_name }}-http.rule=Host(`{{ traefik_host }}.{{ traefik_domain }}`)
  70. - traefik.http.routers.{{ service_name }}-http.entrypoints={{ traefik_entrypoint }}
  71. {% if traefik_tls_enabled %}
  72. - traefik.http.routers.{{ service_name }}-https.service={{ service_name }}-web
  73. - traefik.http.routers.{{ service_name }}-https.rule=Host(`{{ traefik_host }}.{{ traefik_domain }}`)
  74. - traefik.http.routers.{{ service_name }}-https.entrypoints={{ traefik_tls_entrypoint %}
  75. - traefik.http.routers.{{ service_name }}-https.tls=true
  76. - traefik.http.routers.{{ service_name }}-https.tls.certresolver={{ traefik_tls_certresolver }}
  77. {% endif %}
  78. {% endif %}
  79. {#
  80. Deploy configuration for Swarm mode:
  81. - Configure replicas or global mode, placement constraints, and restart policy
  82. - Traefik: Labels for reverse proxy integration (Swarm mode)
  83. - Resources: Set CPU/memory limits and reservations
  84. #}
  85. {% if swarm_enabled %}
  86. deploy:
  87. {% if swarm_placement_mode == 'replicated' %}
  88. replicas: {{ swarm_replicas }}
  89. placement:
  90. constraints:
  91. - node.hostname == {{ swarm_placement_host }}
  92. {% else %}
  93. mode: global
  94. {% endif %}
  95. {#
  96. When traefik_enabled is set in swarm mode, add traefik labels
  97. (optionally enable TLS if traefik_tls_enabled is set)
  98. #}
  99. {% if traefik_enabled %}
  100. labels:
  101. - traefik.enable=true
  102. - traefik.docker.network={{ traefik_network }}
  103. - traefik.http.services.{{ service_name }}-web.loadbalancer.server.port=3000
  104. - traefik.http.routers.{{ service_name }}-http.service={{ service_name }}-web
  105. - traefik.http.routers.{{ service_name }}-http.rule=Host(`{{ traefik_host }}.{{ traefik_domain }}`)
  106. - traefik.http.routers.{{ service_name }}-http.entrypoints={{ traefik_entrypoint }}
  107. {% if traefik_tls_enabled %}
  108. - traefik.http.routers.{{ service_name }}-https.service={{ service_name }}-web
  109. - traefik.http.routers.{{ service_name }}-https.rule=Host(`{{ traefik_host }}.{{ traefik_domain }}`)
  110. - traefik.http.routers.{{ service_name }}-https.entrypoints={{ traefik_tls_entrypoint }}
  111. - traefik.http.routers.{{ service_name }}-https.tls=true
  112. - traefik.http.routers.{{ service_name }}-https.tls.certresolver={{ traefik_tls_certresolver }}
  113. {% endif %}
  114. {% endif %}
  115. {% if resources_enabled %}
  116. resources:
  117. limits:
  118. cpus: '{{ resources_cpu_limit }}'
  119. memory: {{ resources_memory_limit }}
  120. reservations:
  121. cpus: '{{ resources_cpu_reservation }}'
  122. memory: {{ resources_memory_reservation }}
  123. {% endif %}
  124. {% endif %}
  125. {#
  126. Network definitions (only when Traefik is enabled):
  127. - Traefik network: always external (managed by Traefik)
  128. #}
  129. {% if traefik_enabled %}
  130. networks:
  131. {{ traefik_network }}:
  132. external: true
  133. {% endif %}
  134. {#
  135. Volume definitions (only when volume_mode is 'local'):
  136. - config: Dashboard configuration files
  137. - images: Custom images for dashboard
  138. - icons: Custom icons for services
  139. #}
  140. {% if volume_mode == 'local' %}
  141. volumes:
  142. {{ service_name }}_config:
  143. {{ service_name }}_images:
  144. {{ service_name }}_icons:
  145. {% endif %}