services:
    frontend:
        container_name: shop_frontend
        build:
            context: ./frontend
        ports:
            - "3000:3000"
        depends_on:
            - django
        networks:
            - default
        environment:
            - API_BASE_URL=https://api.heymlz.com
            - DEBUG=false
            - NUXT_IMAGE_DOMAINS=https://c262408.parspack.net
        restart: always

    django:
        container_name: shop_backend
        build:
            context: ./backend
        ports:
            - "8000:8000"
        depends_on:
            - db
        volumes:
            - ./backend:/app
            - /root/vol/shop/media:/app/media
            - /root/vol/shop/static:/app/static
        networks:
            - default
        restart: always

    db:
        container_name: shop_db
        image: postgres:16
        environment:
            POSTGRES_DB: hshop
            POSTGRES_USER: byeto
            POSTGRES_PASSWORD: vuhbyq-cypMu0-sirbon
        volumes:
            - postgres_data:/var/lib/postgresql/data
        ports:
            - "5434:5432"
        networks:
            - default
        restart: always

    # db-backup:
    #     container_name: shop_backup
    #     build:
    #         context: ./backup
    #     depends_on:
    #         - db
    #     environment:
    #         - PG_HOST=db
    #         - PG_PORT=5432
    #         - PG_DATABASE=hshop
    #         - PG_USER=byeto
    #         - PG_PASSWORD=vuhbyq-cypMu0-sirbon  
    #         - TELEGRAM_BOT_TOKEN=7068288679:AAGecMnyt9A6R78OQu8nQeISMK1LepX718g
    #         - TELEGRAM_CHAT_ID=1198382521
    #         - TELEGRAM_CHAT_ID2=5115366609
    #     volumes:
    #         - backups:/backups
    #     networks:
    #         - default
    #     restart: always

    db-backup:
        container_name: hshop_backup_v2
        image: greenstorm911/db-backup-with-docker:v1.1.0

        depends_on:
            - db
        
        environment:
            - DB_TYPE=postgresql
            - DB_HOST=db
            - DB_PORT=5432
            - DB_USER=byeto
            - DB_PASSWORD=vuhbyq-cypMu0-sirbon
            - DB_DATABASE=hshop
            - BACKUP_DIR=/backups
            - BACKUP_RETENTION_COUNT=10
            - BACKUP_COMPRESSION=zip
            - CRON_SCHEDULE=0 */6 * * *
            - TELEGRAM_ENABLED=false
            - EMAIL_ENABLED=true
            - EMAIL_SMTP_SERVER=smtp.gmail.com
            - EMAIL_SMTP_PORT=587
            - EMAIL_USERNAME=ftp.notif.manager@gmail.com
            - EMAIL_PASSWORD=ldufbjmidlsosmgq
            - EMAIL_FROM=ftp.notif.manager@gmail.com
            - EMAIL_TO=byeto.net@gmail.com
            - LANGUAGE=fa
            - SHOW_STAR_MESSAGE=false
            - LOG_LEVEL=INFO
            - LOG_FILE=/var/log/backup/backup.log

        volumes:
            - backups:/backups

        networks:
            - default


    redis:
        container_name: hshop_redis
        image: redis:alpine
        ports:
            - "6379:6379"
        networks:
            - default
        restart: always

    celery_worker:
        container_name: shop_celery_worker
        build:
            context: ./backend
        command: celery -A core worker --loglevel=info
        depends_on:
            - django
            - redis
        volumes:
            - ./backend:/app
        environment:
            - CELERY_BROKER_URL=redis://redis:6379/0
        networks:
            - default
        restart: always

    celery_beat:
        container_name: shop_celery_beat
        build:
            context: ./backend
        command: celery -A core beat --loglevel=info
        depends_on:
            - django
            - redis
        volumes:
            - ./backend:/app
        environment:
            - CELERY_BROKER_URL=redis://redis:6379/0
        networks:
            - default
        restart: always


volumes:
    postgres_data:
    media_data:
    static_data:
    backups:
networks:
    default: