# Docker Compose for Pingap - High-performance reverse proxy
# https://pingap.io/

x-defaults: &defaults
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: 100m
      max-file: '3'

services:
  pingap:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}vicanso/pingap:${PINGAP_VERSION:-0.12.7-full}
    ports:
      - '${PINGAP_HTTP_PORT_OVERRIDE:-80}:80'
      - '${PINGAP_HTTPS_PORT_OVERRIDE:-443}:443'
    volumes:
      - pingap_data:/opt/pingap
    environment:
      - TZ=${TZ:-UTC}
      - PINGAP_CONF=/opt/pingap/conf
      - PINGAP_ADMIN_ADDR=${PINGAP_ADMIN_ADDR:-0.0.0.0:80/pingap}
      - PINGAP_ADMIN_USER=${PINGAP_ADMIN_USER:-admin}
      - PINGAP_ADMIN_PASSWORD=${PINGAP_ADMIN_PASSWORD:-password}
    command:
      - pingap
      - --autoreload
    healthcheck:
      test: ["CMD-SHELL", "bash -c 'echo >/dev/tcp/localhost/80' || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 5s
    deploy:
      resources:
        limits:
          cpus: ${PINGAP_CPU_LIMIT:-1.0}
          memory: ${PINGAP_MEMORY_LIMIT:-512M}
        reservations:
          cpus: ${PINGAP_CPU_RESERVATION:-0.5}
          memory: ${PINGAP_MEMORY_RESERVATION:-256M}

volumes:
  pingap_data:
