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

services:
  gpustack:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}gpustack/gpustack:${GPUSTACK_VERSION:-v0.7.1}
    ports:
      - '${GPUSTACK_PORT_OVERRIDE:-80}:80'
    volumes:
      - gpustack_data:/var/lib/gpustack
    environment:
      - TZ=${TZ:-UTC}
      - GPUSTACK_DEBUG=${GPUSTACK_DEBUG:-false}
      - GPUSTACK_HOST=${GPUSTACK_HOST:-0.0.0.0}
      - GPUSTACK_PORT=${GPUSTACK_PORT:-80}
      - GPUSTACK_TOKEN=${GPUSTACK_TOKEN:-}
      - GPUSTACK_BOOTSTRAP_PASSWORD=${GPUSTACK_BOOTSTRAP_PASSWORD:-admin}
      - HF_TOKEN=${HF_TOKEN:-}
    ipc: host
    deploy:
      resources:
        limits:
          cpus: ${GPUSTACK_CPU_LIMIT:-8.0}
          memory: ${GPUSTACK_MEMORY_LIMIT:-8G}
        reservations:
          cpus: ${GPUSTACK_CPU_RESERVATION:-0.1}
          memory: ${GPUSTACK_MEMORY_RESERVATION:-4G}
          devices:
            - driver: nvidia
              device_ids: ['0']
              capabilities: [gpu]
    healthcheck:
      test: [CMD, wget, --no-verbose, --tries=1, --spider, 'http://localhost:80/health']
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

volumes:
  gpustack_data:
