version: "3"
services:
  app:
    image: jc21/nginx-proxy-manager:latest
    container_name: nginx-proxy-manager
    environment:
      DB_MYSQL_HOST: 'db'
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: 'npm'
      DB_MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      DB_MYSQL_NAME: 'npm'
    volumes:
      - /portainer/Files/AppData/Config/nginx-proxy-manager/config.json:/app/config/production.json
      - /portainer/Files/AppData/Config/nginx-proxy-manager/data:/data
      - /portainer/Files/AppData/Config/nginx-proxy-manager/letsencrypt:/etc/letsencrypt
    depends_on:
      - db
      - stats
    ports:
      - 80:80
      - 443:443
      - 81:81
    restart: unless-stopped
  db:
    image: linuxserver/mariadb:latest
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: npm
      MYSQL_USER: npm
      MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}

    volumes:
      - /portainer/Files/AppData/Config/nginx-proxy-manager/database:/config

  stats:
    image: justsky/goaccess-for-nginxproxymanager:latest
    restart: unless-stopped
    environment:
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}
      SKIP_ARCHIVED_LOGS: "${SKIP_ARCHIVED_LOGS}"
      BASIC_AUTH: "${BASIC_AUTH}"
      BASIC_AUTH_USERNAME: ${BASIC_AUTH_USERNAME}
      BASIC_AUTH_PASSWORD: ${BASIC_AUTH_PASSWORD}
    ports:
      - 7880:7880
 
    volumes:
      - /portainer/Files/AppData/Config/nginx-proxy-manager/data/logs:/opt/log:ro
