version: '3.8'

services:
  joomla-db:
    image: mysql:5.7
    container_name: joomla-mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: joomla_root_pass
      MYSQL_DATABASE: joomla_db
      MYSQL_USER: joomla_user
      MYSQL_PASSWORD: joomla_pass
    volumes:
      - joomla-db-data:/var/lib/mysql
    networks:
      - joomla-net

  joomla-web:
    image: php:7.4-apache
    container_name: joomla-web
    restart: always
    ports:
      - "8080:80"
    volumes:
      - ./joomla:/var/www/html
    depends_on:
      - joomla-db
    networks:
      - joomla-net
    environment:
      - JOOMLA_DB_HOST=joomla-db
      - JOOMLA_DB_NAME=joomla_db
      - JOOMLA_DB_USER=joomla_user
      - JOOMLA_DB_PASSWORD=joomla_pass

  joomla-web-php83:
    image: wordpress:php8.3-apache
    container_name: joomla-web-php83
    restart: always
    entrypoint: ["apache2-foreground"]
    ports:
      - "8083:80"
    volumes:
      - ./joomla-php83:/var/www/html
    depends_on:
      - joomla-db
    networks:
      - joomla-net
    environment:
      - JOOMLA_DB_HOST=joomla-db
      - JOOMLA_DB_NAME=joomla_db
      - JOOMLA_DB_USER=joomla_user
      - JOOMLA_DB_PASSWORD=joomla_pass

  wordpress-db:
    image: mysql:8.0
    container_name: wordpress-mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: wordpress_root_pass
      MYSQL_DATABASE: wordpress_db
      MYSQL_USER: wordpress_user
      MYSQL_PASSWORD: wordpress_pass
    volumes:
      - wordpress-db-data:/var/lib/mysql
    networks:
      - wordpress-net

  wordpress-web:
    image: wordpress:latest
    container_name: wordpress-web
    restart: always
    ports:
      - "8081:80"
    volumes:
      - ./wordpress:/var/www/html
      - ./joomla/images:/var/www/joomla-images:ro
    depends_on:
      - wordpress-db
    networks:
      - wordpress-net
    environment:
      WORDPRESS_DB_HOST: wordpress-db
      WORDPRESS_DB_NAME: wordpress_db
      WORDPRESS_DB_USER: wordpress_user
      WORDPRESS_DB_PASSWORD: wordpress_pass

volumes:
  joomla-db-data:
  wordpress-db-data:

networks:
  joomla-net:
  wordpress-net:
