# Please see https://github.com/maelgangloff/domain-watchdog

services:
    domainwatchdog:
        image: maelgangloff/domain-watchdog:latest
        container_name: domainwatchdog_app
        restart: unless-stopped
        env_file:
            - .env.local
        environment:
            APP_ENV: prod
            SERVER_NAME: ${SERVER_NAME:-:80}
            DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8}
            MESSENGER_ASYNC_TRANSPORT_DSN: redis://valkey:6379/messages
            MESSENGER_RDAP_LOW_TRANSPORT_DSN: redis://valkey:6379/messages-rdap-low
            MESSENGER_RDAP_HIGH_TRANSPORT_DSN: redis://valkey:6379/messages-rdap-high
        volumes:
            - caddy_data:/data
            - caddy_config:/config
            - ./public/content:/app/public/content
        ports:
            - "127.0.0.1:8080:80"
        depends_on:
            - database

    php-worker:
        image: maelgangloff/domain-watchdog:latest
        container_name: domainwatchdog_worker
        restart: always
        command: php /app/bin/console messenger:consume --all --time-limit=3600 -vvv
        env_file:
            - .env.local
        environment:
            APP_ENV: prod
            DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8}
            MESSENGER_ASYNC_TRANSPORT_DSN: redis://valkey:6379/messages
            MESSENGER_RDAP_LOW_TRANSPORT_DSN: redis://valkey:6379/messages-rdap-low
            MESSENGER_RDAP_HIGH_TRANSPORT_DSN: redis://valkey:6379/messages-rdap-high
            MESSENGER_CONSUMER_NAME: worker
        depends_on:
            - database
        healthcheck:
            test: [ ]
            disable: true

    database:
        image: postgres:${POSTGRES_VERSION:-16}-alpine
        container_name: domainwatchdog_db
        restart: unless-stopped
        environment:
            POSTGRES_DB: ${POSTGRES_DB:-app}
            POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
            POSTGRES_USER: ${POSTGRES_USER:-app}
        healthcheck:
            test: [ "CMD", "pg_isready", "-d", "${POSTGRES_DB:-app}", "-U", "${POSTGRES_USER:-app}" ]
            timeout: 5s
            retries: 5
            start_period: 60s
        volumes:
            - database_data:/var/lib/postgresql/data:rw

    valkey:
        image: valkey/valkey
        container_name: valkey
        restart: always

#  influxdb2:
#    image: influxdb:2
#    ports:
#      - "127.0.0.1:8086:8086"
#    environment:
#      DOCKER_INFLUXDB_INIT_MODE: setup
#      DOCKER_INFLUXDB_INIT_USERNAME: USERNAME # Please modify
#      DOCKER_INFLUXDB_INIT_PASSWORD: PASSWORD # Please modify
#      DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: my-super-secret-auth-token # Please modify
#      DOCKER_INFLUXDB_INIT_RETENTION: 0
#      DOCKER_INFLUXDB_INIT_ORG: domainwatchdog
#      DOCKER_INFLUXDB_INIT_BUCKET: domainwatchdog

volumes:
    caddy_data:
    caddy_config:
    database_data:
