services:
    api:
        container_name: ${CONTAINER_NAME}
        image: evoapicloud/evolution-api:${APP_VERSION}
        restart: always
        volumes:
            - ./instances:/evolution/instances
        environment:
            EVO_DB_HOST: ${PANEL_DB_HOST}:${PANEL_DB_PORT}
            EVO_DB_NAME: ${PANEL_DB_NAME}
            EVO_DB_USER: ${PANEL_DB_USER}
            EVO_DB_PASSWORD: ${PANEL_DB_USER_PASSWORD}
            # === Server ===
            SERVER_TYPE: http
            SERVER_PORT: 8080
            SERVER_URL: ${APP_PROTOCOL:-http}://${APP_DOMAIN}/
            
            # === Auth ===
            AUTHENTICATION_API_KEY: ${AUTH_API_KEY}
            AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES: true
            
            # === CORS ===
            CORS_ORIGIN: "*"
            CORS_METHODS: GET,POST,PUT,DELETE
            CORS_CREDENTIALS: true
            
            # === Logs ===
            LOG_LEVEL: ERROR,WARN,INFO,DEBUG,VERBOSE,WEBHOOKS,WEBSOCKET
            LOG_COLOR: true
            LOG_BAILEYS: error
            
            # === Database ===
            DATABASE_ENABLED: true
            DATABASE_PROVIDER: postgresql
            # Use placeholders no tutorial:
            DATABASE_CONNECTION_URI: postgresql://${PANEL_DB_USER}:${PANEL_DB_USER_PASSWORD}@${PANEL_DB_HOST}:${PANEL_DB_PORT}/${PANEL_DB_NAME}?schema=public
            
            # === Cache / Redis ===
            CACHE_REDIS_ENABLED: true
            # Use placeholders no tutorial:
            CACHE_REDIS_URI: redis://:${PANEL_REDIS_ROOT_PASSWORD}@${PANEL_REDIS_HOST}:${PANEL_REDIS_PORT}/0
            CACHE_REDIS_TTL: 604800
            CACHE_REDIS_PREFIX_KEY: evolution
            CACHE_REDIS_SAVE_INSTANCES: false
            CACHE_LOCAL_ENABLED: false
            
            # === Session ===
            CONFIG_SESSION_PHONE_CLIENT: Evolution API
            CONFIG_SESSION_PHONE_NAME: Chrome
            
            # === QrCode ===
            QRCODE_LIMIT: ${QRCODE_LIMIT:-30}
            QRCODE_COLOR: ${QRCODE_COLOR:-#175197}
        networks:
            - icontainer-network
        ports:
            - ${PANEL_APP_PORT_HTTP}:8080
        labels:
            createdBy: "icontainer"
networks:
    icontainer-network:
        external: true