version: '3.8'

services:
  app:
    image: {{DOCKER_IMAGE}}:{{VERSION}}
    container_name: {{INSTALL_ID}}_app
    restart: unless-stopped
    environment:
      - APP_NAME={{APP_NAME}}
      - APP_ENV=production
      - APP_KEY={{APP_KEY}}
      - APP_URL={{APP_URL}}
      - DB_HOST=db
      - DB_DATABASE={{DB_NAME}}
      - DB_USERNAME={{DB_USER}}
      - DB_PASSWORD={{DB_PASS}}
    volumes:
      - ./data/app:/var/www/html/storage
      - ./data/logs:/var/www/html/storage/logs
    networks:
      - {{INSTALL_ID}}_network
{{SHARED_NETWORK_BLOCK}}
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.{{INSTALL_ID}}.rule=Host(`{{DOMAIN}}`)"
      - "traefik.http.routers.{{INSTALL_ID}}.entrypoints=websecure"
      - "traefik.http.routers.{{INSTALL_ID}}.tls.certresolver=letsencrypt"
    deploy:
      resources:
        limits:
          cpus: '{{CPU_LIMIT}}'
          memory: {{MEMORY_LIMIT}}

  db:
    image: mysql:8.0
    container_name: {{INSTALL_ID}}_db
    restart: unless-stopped
    environment:
      - MYSQL_DATABASE={{DB_NAME}}
      - MYSQL_USER={{DB_USER}}
      - MYSQL_PASSWORD={{DB_PASS}}
      - MYSQL_ROOT_PASSWORD={{DB_ROOT_PASS}}
    volumes:
      - ./data/database:/var/lib/mysql
    networks:
      - {{INSTALL_ID}}_network
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 512M

networks:
  {{INSTALL_ID}}_network:
    driver: bridge
{{SHARED_NETWORK_DECLARATION}}
