services:
    www:
        build: .
        user: 1000:1000
        container_name: ${APP_NAME}-www
        ports:
          - ${HOST_PORT:-80}:80
          - ${HOST_PORT_SSL:-443}:443
        hostname: ${HOST_NAME:-localhost}
        volumes:
            - ./:/var/www/html/
            - ./config/php.ini:/usr/local/etc/php/php.ini
        links:
            - db
        networks:
            - default
        extra_hosts:
          - host.docker.internal:host-gateway

    db:
        image: mysql:8.4.2
        container_name: ${APP_NAME}-db
        command: ["mysqld", "--mysql-native-password=ON"]
        hostname: ${APP_NAME}db
        ports:
            - ${HOST_DB_PORT:-3306}:3306
        environment:
            MYSQL_DATABASE: ${DB_NAME}
            MYSQL_USER: ${DB_USER}
            MYSQL_PASSWORD: ${DB_PASSWORD}
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
        volumes:
            - ./dump:/docker-entrypoint-initdb.d
            - ${HOST_DB_VOLUME:-persistent}:/var/lib/mysql
        networks:
            - default

    wpcli:
        image: wordpress:cli-php8.2
        container_name: ${APP_NAME}-wpcli
        depends_on:
            - db
        user: 1000:1000
        command: tail -f /dev/null
        volumes:
            - ./:/var/www/html
        environment:
            WORDPRESS_DB_HOST: db:db
        networks:
            - default

    node:
        image: node:latest
        container_name: ${APP_NAME}-node
        user: 1000:1000
        working_dir: /app
        volumes:
            - ./:/app
    phpmyadmin:
        image: phpmyadmin:latest
        container_name: ${APP_NAME}-pma
        links:
            - db:db
        ports:
            - ${HOST_PHPMYADMIN_PORT:-8383}:80
        depends_on:
            - db
        environment:
            MYSQL_USER: ${DB_USER}
            MYSQL_PASSWORD: ${DB_PASSWORD}
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
        networks:
            - default

volumes:
    persistent:
