version: "3.3"
services:
    nginx:
        deploy:
            resources:
                limits:
                    cpus: "0.5"
                    memory: "512M"
        container_name: nginx_KATADATA
        image: nginx:alpine
        ports:
            - 8004:80
        depends_on:
            - app
        volumes:
            - ./:/var/www/html
            - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
        restart: always
    app:
        container_name: portal_KATADATA
        build:
            context: ./php
            dockerfile: Dockerfile
        image: aptika:laravel-12
        volumes:
            - ./:/var/www/html
        working_dir: /var/www/html
        restart: always
    php:
        container_name: php_KATADATA
        # image: php:8.2-fpm-alpine
        image: aptika:laravel-12
        depends_on:
            - app
        volumes:
            - ./:/var/www/html
            - ./php/php.ini:/usr/local/etc/php/php.ini
        restart: always
    redis:
        image: redis:7-alpine
        container_name: ${SERVER_NAME:-KATADATA}_redis
        command: >
            redis-server --appendonly yes
                         --maxmemory 2gb
                         --maxmemory-policy allkeys-lru
        volumes:
            - redis-data:/data
        healthcheck:
            test: ["CMD", "redis-cli", "ping"]
            interval: 10s
            timeout: 3s
            retries: 10
        restart: unless-stopped
    queue-worker:
        image: aptika:laravel-12
        container_name: ${SERVER_NAME:-KATADATA}_queue_worker
        depends_on:
            - redis
        volumes:
            - ./:/var/www/html
        command: php /var/www/html/artisan queue:work redis --sleep=3 --tries=1 --timeout=0 --memory=1024
        restart: unless-stopped
    scheduler:
        depends_on:
            - app
        image: aptika:laravel-12
        volumes:
            - ./:/var/www/html
        container_name: ${SERVER_NAME:-KATADATA}_scheduler
        command: ["/usr/sbin/crond", "-n"] # <- HAPUS "-l", cukup -n  # <- ganti ini, pakai crond
        restart: unless-stopped
volumes:
    redis-data:
