### ----------------------------------------------------
### -- CLI::Wordpress
### -- Licenses: Artistic-2.0
### -- Authors: librasteve
### -- File: resources/wordpress/docker-compose.yaml
### ----------------------------------------------------
version: "3"

services:
  db:
    image: %DB-IMAGE%
    container_name: db
    restart: unless-stopped
    env_file: .env
    environment:
      - MYSQL_DATABASE=wordpress
    volumes:
      - dbdata:/var/lib/mysql
    command: "--default-authentication-plugin=mysql_native_password"
    networks:
      - app-network

  wordpress:
    depends_on:
      - db
    image: %WORDPRESS-IMAGE%
    container_name: wordpress
    restart: unless-stopped
    env_file: .env
    environment:
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_USER=$MYSQL_USER
      - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
      - WORDPRESS_DB_NAME=wordpress
    volumes:
      - wordpress:/var/www/html
      - ./php-conf/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    networks:
      - app-network

  webserver:
    depends_on:
      - wordpress
    image: %WEBSERVER-IMAGE%
    container_name: webserver
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - wordpress:/var/www/html
      - ./nginx-conf:/etc/nginx/conf.d
      - certbot-etc:/etc/letsencrypt
    networks:
      - app-network

  certbot:
    depends_on:
      - webserver
    image: %CERTBOT-IMAGE%
    container_name: certbot
    volumes:
      - certbot-etc:/etc/letsencrypt
      - wordpress:/var/www/html

  wpcli:
    depends_on:
      - wordpress
    image: %WPCLI-IMAGE%
    container_name: wpcli
    restart: unless-stopped
    command: tail -f /dev/null
    volumes:
      - wordpress:/var/www/html
    environment:
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_USER=$MYSQL_USER
      - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
      - WORDPRESS_DB_NAME=wordpress
    profiles:
      - dev
    networks:
      - app-network

  git:
    depends_on:
      - wordpress
    image: ubuntu:latest
    container_name: git
    restart: unless-stopped
    command: tail -f /dev/null
    volumes:
      - wordpress:/var/www/html
    networks:
      - app-network

volumes:
  certbot-etc:
  wordpress:
  dbdata:

networks:
  app-network:
    driver: bridge


