services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: brentwood-php:8.3
    container_name: ${PROJECT_NAME}-app
    restart: unless-stopped
    depends_on:
      - mysql
      - redis

    ports:
      - "172.17.0.1:${PORT}:8080"

    environment:
      SSL_MODE: "off"
      PHP_OPCACHE_ENABLE: "1"
      PHP_MEMORY_LIMIT: "512M"
      PHP_POST_MAX_SIZE: "100M"
      PHP_UPLOAD_MAX_FILE_SIZE: "100M"
      AUTORUN_ENABLED: "false"

    volumes:
      - ./laravel:/var/www/html

    mem_limit: 1g
    cpus: 1.0

  mysql:
    image: mysql:8.0
    container_name: ${PROJECT_NAME}-mysql
    restart: unless-stopped

    environment:
      MYSQL_ROOT_PASSWORD: brentwood_root_pw
      MYSQL_DATABASE: brentwood
      MYSQL_USER: brentwood
      MYSQL_PASSWORD: brentwood_pw

    volumes:
      - ./mysql-data:/var/lib/mysql

    mem_limit: 1g
    cpus: 1.0

  redis:
    image: redis:7-alpine
    container_name: ${PROJECT_NAME}-redis
    restart: unless-stopped

    mem_limit: 256m
    cpus: 0.5

  # --- WordPress (migration target: Laravel -> WordPress) ---
  # Served at brentwoodwp.demoing.info via Caddy. Own DB, isolated from Laravel.
  wp:
    image: wordpress:php8.3-apache
    container_name: ${PROJECT_NAME}-wp
    restart: unless-stopped
    depends_on:
      - wp-db

    ports:
      - "172.17.0.1:5030:80"

    environment:
      WORDPRESS_DB_HOST: wp-db:3306
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: c016aac807d6ca4420ed147633a55df2
      WORDPRESS_CONFIG_EXTRA: |
        define('WP_HOME', 'https://brentwoodwp.demoing.info');
        define('WP_SITEURL', 'https://brentwoodwp.demoing.info');

    volumes:
      - ./wp:/var/www/html

    mem_limit: 1g
    cpus: 1.0

  wp-db:
    image: mariadb:11
    container_name: ${PROJECT_NAME}-wp-db
    restart: unless-stopped

    environment:
      MARIADB_ROOT_PASSWORD: 8ef1e3008ea849bfb6534673dd5fd1c2
      MARIADB_DATABASE: wordpress
      MARIADB_USER: wordpress
      MARIADB_PASSWORD: c016aac807d6ca4420ed147633a55df2

    volumes:
      - ./wp-db-data:/var/lib/mysql

    mem_limit: 1g
    cpus: 1.0
