services:
  app:
    container_name: shams_app
    image: shams:latest
    restart: unless-stopped
    networks:
      - global_network
    volumes:
      - shams_laravel_storage:/var/www/html/storage
    ports:
      - "${PORT_MAPPING}"
    mem_limit: ${MEM}
    memswap_limit: ${SWAP}
    cpus: ${CPU}
    command: sh -c "php-fpm -D && nginx -g 'daemon off;'"
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  worker:
    container_name: shams_worker
    image: shams:latest
    restart: unless-stopped
    networks:
      - global_network
    volumes:
      - shams_laravel_storage:/var/www/html/storage
    mem_limit: ${MEM}
    memswap_limit: ${SWAP}
    cpus: ${CPU}
    depends_on:
      - app
    command: ["supervisord", "-c", "/etc/supervisord.conf"]
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  scheduler:
    container_name: shams_scheduler
    image: shams:latest
    restart: unless-stopped
    networks:
      - global_network
    volumes:
      - shams_laravel_storage:/var/www/html/storage
    mem_limit: ${MEM}
    memswap_limit: ${SWAP}
    cpus: ${CPU}
    depends_on:
      - app
    command: ["supercronic", "/etc/cron.d/laravel-scheduler"]
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

networks:
  global_network:
    external: true

volumes:
  shams_laravel_storage:
