# Docker Compose Template for Compose Anything # This template provides a standardized structure for all services # Copy this template when creating new services x-defaults: &defaults restart: unless-stopped logging: driver: json-file options: max-size: 100m max-file: "3" #! Example service structure: services: service-name: <<: *defaults #! Use ${GLOBAL_REGISTRY} for a global registry prefix if defined #! If not pulls from Docker Hub by default, use ${GHCR_REGISTRY} for GitHub Container Registry, etc. #! e.g. ${GLOBAL_REGISTRY:-}httpd:${APACHE_VERSION:-2.4.62-alpine3.20} #! Use ${SERVICE_NAME_VERSION} to specify the image version, e.g., 3.2.1 image: ${GLOBAL_REGISTRY:-}service-image:${SERVICE_NAME_VERSION:-3.2.1} #! Do not add container_name to allow scaling and avoid name conflicts ports: - "${SERVICE_NAME_PORT_OVERRIDE:-8080}:8080" volumes: - service_name_data:/data environment: - TZ=${TZ:-UTC} #! Set timezone, default to UTC - ENV_VAR=${ENV_VAR:-default_value} healthcheck: test: ["CMD", "command", "to", "check", "health"] interval: 30s timeout: 10s retries: 3 start_period: 10s deploy: resources: limits: cpus: ${SERVICE_NAME_CPU_LIMIT:-0.50} memory: ${SERVICE_NAME_MEMORY_LIMIT:-256M} reservations: cpus: ${SERVICE_NAME_CPU_RESERVATION:-0.25} memory: ${SERVICE_NAME_MEMORY_RESERVATION:-128M} volumes: service_name_data: