version: '3.8'

services:
  registry:
    image: registry:2.8
    container_name: provisioning-registry
    ports:
      - "5000:5000"
      - "5001:5001"  # Debug/metrics port
    volumes:
      - ./config.yml:/etc/docker/registry/config.yml:ro
      - registry-data:/var/lib/registry
      - ./certs:/etc/docker/registry/certs:ro
      - ./htpasswd:/etc/docker/registry/htpasswd:ro
    restart: unless-stopped
    environment:
      - REGISTRY_HTTP_SECRET=provisioning-secret-key-change-me
      - REGISTRY_STORAGE_DELETE_ENABLED=true
    healthcheck:
      test: ["CMD", "wget", "--spider", "-q", "http://localhost:5000/v2/"]
      interval: 30s
      timeout: 10s
      retries: 3
    networks:
      - provisioning-net

  # Optional: Redis for caching
  redis:
    image: redis:7-alpine
    container_name: provisioning-registry-cache
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    restart: unless-stopped
    command: redis-server --appendonly yes
    networks:
      - provisioning-net

  # Optional: Registry UI
  registry-ui:
    image: joxit/docker-registry-ui:latest
    container_name: provisioning-registry-ui
    ports:
      - "8080:80"
    environment:
      - SINGLE_REGISTRY=true
      - REGISTRY_TITLE=Provisioning OCI Registry
      - REGISTRY_URL=http://registry:5000
      - DELETE_IMAGES=true
      - SHOW_CONTENT_DIGEST=true
      - NGINX_PROXY_PASS_URL=http://registry:5000
      - SHOW_CATALOG_NB_TAGS=true
      - CATALOG_MIN_BRANCHES=1
      - CATALOG_MAX_BRANCHES=1
      - TAGLIST_PAGE_SIZE=100
      - REGISTRY_SECURED=false
      - CATALOG_ELEMENTS_LIMIT=1000
    depends_on:
      - registry
    networks:
      - provisioning-net

networks:
  provisioning-net:
    driver: bridge

volumes:
  registry-data:
  redis-data:
