version: "3.9"
services:
      
  wordpress:
    container_name: wordpress
    image: wordpress:6.5.2
    environment:
      - WORDPRESS_DB_HOST=wordpress-db
      - WORDPRESS_DB_NAME=wordpress
      - WORDPRESS_DB_USER=tipi
      - WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
    volumes:
      - ${APP_DATA_DIR}/data/wordpress:/var/www/html
    ports:
      - ${APP_PORT}:80
    restart: unless-stopped
    depends_on:
      - wordpress-db
    networks:
      - tipi_main_network
    labels:
        # Main
        traefik.enable: true
        traefik.http.middlewares.wordpress-web-redirect.redirectscheme.scheme: https
        traefik.http.services.wordpress-web.loadbalancer.server.port: 80
        # Web
        traefik.http.routers.wordpress-web-insecure.rule: Host(`${APP_DOMAIN}`)
        traefik.http.routers.wordpress-web-insecure.entrypoints: web
        traefik.http.routers.wordpress-web-insecure.service: wordpress-web
        traefik.http.routers.wordpress-web-insecure.middlewares: wordpress-web-redirect
        # Websecure
        traefik.http.routers.wordpress-web.rule: Host(`${APP_DOMAIN}`)
        traefik.http.routers.wordpress-web.entrypoints: websecure
        traefik.http.routers.wordpress-web.service: wordpress-web
        traefik.http.routers.wordpress-web.tls.certresolver: myresolver
        # Local domain
        traefik.http.routers.wordpress-web-local-insecure.rule: Host(`wordpress-web.${LOCAL_DOMAIN}`)
        traefik.http.routers.wordpress-web-local-insecure.entrypoints: web
        traefik.http.routers.wordpress-web-local-insecure.service: wordpress-web
        traefik.http.routers.wordpress-web-local-insecure.middlewares: wordpress-web-redirect
        # Local domain secure
        traefik.http.routers.wordpress-web-local.rule: Host(`wordpress-web.${LOCAL_DOMAIN}`)
        traefik.http.routers.wordpress-web-local.entrypoints: websecure
        traefik.http.routers.wordpress-web-local.service: wordpress-web
        traefik.http.routers.wordpress-web-local.tls: true

  wordpress-db:
    container_name: wordpress-db
    image: mariadb:11.1.3
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=tipi
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - ${APP_DATA_DIR}/data/mariadb:/var/lib/mysql
    restart: unless-stopped
    networks:
      - tipi_main_network