#
services:
  db:
    image: 'jc21/mariadb-aria:latest'
    container_name: npm-db
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=rhDGjilZm6XEMJ
      - MYSQL_DATABASE=npm
      - MYSQL_USER=npm
      - MYSQL_PASSWORD=rhDGjilZm6XEMJ
      - MARIADB_AUTO_UPGRADE=1
    volumes:
      - /opt/Docker-Deployments/NginxProxyManager/data/mysql:/var/lib/mysql
    networks:
      - internal
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u$MYSQL_USER", "-p$MYSQL_PASSWORD"]
      interval: 20s
      timeout: 5s
      retries: 5
      start_period: 30s

  nginx-proxy-manager:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: nginx-proxy-manager
    restart: unless-stopped
    environment:
      - TZ=America/New_York
      - DB_MYSQL_HOST=db
      - DB_MYSQL_PORT=3306
      - DB_MYSQL_USER=npm
      - DB_MYSQL_PASSWORD=rhDGjilZm6XEMJ
      - DB_MYSQL_NAME=npm
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - /opt/Docker-Deployments/NginxProxyManager/data/npm:/data
      - /opt/Docker-Deployments/NginxProxyManager/data/letsencrypt:/etc/letsencrypt
      - /opt/Docker-Deployments/NginxProxyManager/logs:/data/logs
    depends_on:
      - db
    networks:
      - internal
      - external
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:81/api/status"]
      interval: 20s
      timeout: 5s
      retries: 5
      start_period: 40s

networks:
  internal:
    external: true
  external:
    external: true