{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://meldestelle.at/schemas/docker-versions.json",
  "title": "Docker Versions TOML Schema",
  "description": "Schema for docker/versions.toml - centralized Docker version management",
  "type": "object",
  "properties": {
    "versions": {
      "type": "object",
      "description": "Central version definitions for all Docker components",
      "properties": {
        "gradle": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
          "description": "Gradle version for build tools",
          "examples": ["9.0.0", "8.14.0"]
        },
        "java": {
          "type": "string",
          "pattern": "^[0-9]+$",
          "description": "Java version (LTS recommended)",
          "examples": ["21", "17", "11"]
        },
        "node": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
          "description": "Node.js version for client builds",
          "examples": ["20.12.0", "18.19.0"]
        },
        "nginx": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+-alpine$",
          "description": "Nginx version with Alpine base",
          "examples": ["1.25-alpine", "1.24-alpine"]
        },
        "alpine": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+$",
          "description": "Alpine Linux base image version",
          "examples": ["3.19", "3.18"]
        },
        "eclipse-temurin-jdk": {
          "type": "string",
          "pattern": "^[0-9]+-jdk-alpine$",
          "description": "Eclipse Temurin JDK image tag",
          "examples": ["21-jdk-alpine", "17-jdk-alpine"]
        },
        "eclipse-temurin-jre": {
          "type": "string",
          "pattern": "^[0-9]+-jre-alpine$",
          "description": "Eclipse Temurin JRE image tag",
          "examples": ["21-jre-alpine", "17-jre-alpine"]
        },
        "prometheus": {
          "type": "string",
          "pattern": "^v[0-9]+\\.[0-9]+\\.[0-9]+$",
          "description": "Prometheus monitoring version",
          "examples": ["v2.54.1", "v2.47.0"]
        },
        "grafana": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
          "description": "Grafana visualization version",
          "examples": ["11.3.0", "10.1.0"]
        },
        "keycloak": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
          "description": "Keycloak authentication version",
          "examples": ["26.0.7", "25.0.6"]
        },
        "spring-profiles-default": {
          "type": "string",
          "enum": ["default", "dev", "test", "prod"],
          "description": "Default Spring profile for infrastructure services"
        },
        "spring-profiles-docker": {
          "type": "string",
          "enum": ["docker", "dev", "test", "prod"],
          "description": "Spring profile for Docker containers"
        },
        "spring-profiles-prod": {
          "type": "string",
          "enum": ["prod", "production"],
          "description": "Spring profile for production environment"
        },
        "app-version": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
          "description": "Application version for all services",
          "examples": ["1.0.0", "2.1.3"]
        }
      },
      "required": [
        "gradle",
        "java",
        "node",
        "nginx",
        "alpine",
        "prometheus",
        "grafana",
        "keycloak",
        "app-version"
      ],
      "additionalProperties": false
    },
    "service-ports": {
      "type": "object",
      "description": "Centralized port definitions for all services",
      "properties": {
        "api-gateway": {
          "type": "integer",
          "minimum": 8081,
          "maximum": 8081,
          "description": "API Gateway port"
        },
        "auth-server": {
          "type": "integer",
          "minimum": 8087,
          "maximum": 8087,
          "description": "Authentication server port"
        },
        "monitoring-server": {
          "type": "integer",
          "minimum": 8088,
          "maximum": 8088,
          "description": "Monitoring server port"
        },
        "ping-service": {
          "type": "integer",
          "minimum": 8082,
          "maximum": 8082,
          "description": "Ping service port"
        },
        "members-service": {
          "type": "integer",
          "minimum": 8083,
          "maximum": 8083,
          "description": "Members service port"
        },
        "horses-service": {
          "type": "integer",
          "minimum": 8084,
          "maximum": 8084,
          "description": "Horses service port"
        },
        "events-service": {
          "type": "integer",
          "minimum": 8085,
          "maximum": 8085,
          "description": "Events service port"
        },
        "masterdata-service": {
          "type": "integer",
          "minimum": 8086,
          "maximum": 8086,
          "description": "Masterdata service port"
        },
        "postgres": {
          "type": "integer",
          "minimum": 5432,
          "maximum": 5432,
          "description": "PostgreSQL database port"
        },
        "redis": {
          "type": "integer",
          "minimum": 6379,
          "maximum": 6379,
          "description": "Redis cache port"
        },
        "keycloak": {
          "type": "integer",
          "minimum": 8180,
          "maximum": 8180,
          "description": "Keycloak authentication port"
        },
        "consul": {
          "type": "integer",
          "minimum": 8500,
          "maximum": 8500,
          "description": "Consul service discovery port"
        },
        "zookeeper": {
          "type": "integer",
          "minimum": 2181,
          "maximum": 2181,
          "description": "Zookeeper coordination port"
        },
        "kafka": {
          "type": "integer",
          "minimum": 9092,
          "maximum": 9092,
          "description": "Kafka messaging port"
        },
        "prometheus": {
          "type": "integer",
          "minimum": 9090,
          "maximum": 9090,
          "description": "Prometheus monitoring port"
        },
        "grafana": {
          "type": "integer",
          "minimum": 3000,
          "maximum": 3000,
          "description": "Grafana visualization port"
        },
        "web-app": {
          "type": "integer",
          "minimum": 4000,
          "maximum": 4000,
          "description": "Web application port"
        },
        "desktop-app-vnc": {
          "type": "integer",
          "minimum": 5901,
          "maximum": 5901,
          "description": "Desktop app VNC port"
        },
        "desktop-app-novnc": {
          "type": "integer",
          "minimum": 6080,
          "maximum": 6080,
          "description": "Desktop app noVNC web port"
        }
      },
      "required": [
        "api-gateway",
        "auth-server",
        "monitoring-server",
        "ping-service",
        "postgres",
        "redis",
        "keycloak",
        "prometheus",
        "grafana",
        "web-app"
      ],
      "additionalProperties": false
    },
    "port-ranges": {
      "type": "object",
      "description": "Port range definitions for service categories",
      "properties": {
        "infrastructure": {
          "type": "string",
          "pattern": "^[0-9]+-[0-9]+$",
          "description": "Port range for infrastructure services",
          "examples": ["8081-8088"]
        },
        "services": {
          "type": "string",
          "pattern": "^[0-9]+-[0-9]+$",
          "description": "Port range for application services",
          "examples": ["8082-8099"]
        },
        "monitoring": {
          "type": "string",
          "pattern": "^[0-9]+-[0-9]+$",
          "description": "Port range for monitoring services",
          "examples": ["9090-9099"]
        },
        "clients": {
          "type": "string",
          "pattern": "^[0-9]+-[0-9]+$",
          "description": "Port range for client applications",
          "examples": ["4000-4099"]
        },
        "vnc": {
          "type": "string",
          "pattern": "^[0-9]+-[0-9]+$",
          "description": "Port range for VNC connections",
          "examples": ["5901-5999"]
        },
        "debug": {
          "type": "string",
          "pattern": "^[0-9]+-[0-9]+$",
          "description": "Port range for debug connections",
          "examples": ["5005-5009"]
        },
        "system-reserved": {
          "type": "string",
          "pattern": "^[0-9]+-[0-9]+$",
          "description": "System reserved port range",
          "examples": ["0-1023"]
        },
        "ephemeral": {
          "type": "string",
          "pattern": "^[0-9]+-[0-9]+$",
          "description": "Ephemeral port range",
          "examples": ["32768-65535"]
        }
      },
      "required": [
        "infrastructure",
        "services",
        "monitoring",
        "clients",
        "debug"
      ],
      "additionalProperties": false
    },
    "build-args": {
      "type": "object",
      "description": "Build argument categories for different service types",
      "properties": {
        "global": {
          "type": "array",
          "description": "Global build arguments used by all services",
          "items": {
            "type": "string",
            "enum": [
              "GRADLE_VERSION",
              "JAVA_VERSION",
              "BUILD_DATE",
              "VERSION"
            ]
          },
          "uniqueItems": true
        },
        "spring-services": {
          "type": "array",
          "description": "Spring Boot service-specific build arguments",
          "items": {
            "type": "string",
            "enum": [
              "SPRING_PROFILES_ACTIVE",
              "SERVICE_PATH",
              "SERVICE_NAME",
              "SERVICE_PORT"
            ]
          },
          "uniqueItems": true
        },
        "web-clients": {
          "type": "array",
          "description": "Web client-specific build arguments",
          "items": {
            "type": "string",
            "enum": [
              "NODE_VERSION",
              "NGINX_VERSION",
              "CLIENT_PATH",
              "CLIENT_MODULE",
              "CLIENT_NAME"
            ]
          },
          "uniqueItems": true
        }
      },
      "required": ["global"],
      "additionalProperties": false
    },
    "categories": {
      "type": "object",
      "description": "Service category configurations",
      "properties": {
        "services": {
          "type": "object",
          "properties": {
            "default-spring-profile": {
              "type": "string",
              "enum": ["docker", "dev", "test", "prod"]
            },
            "default-port-start": {
              "type": "integer",
              "minimum": 8082,
              "maximum": 8099
            },
            "services": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "ping-service",
                  "members-service",
                  "horses-service",
                  "events-service",
                  "masterdata-service"
                ]
              },
              "uniqueItems": true
            }
          },
          "required": ["services"],
          "additionalProperties": false
        },
        "infrastructure": {
          "type": "object",
          "properties": {
            "default-spring-profile": {
              "type": "string",
              "enum": ["default", "dev", "test", "prod"]
            },
            "services": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "gateway",
                  "auth-server",
                  "monitoring-server"
                ]
              },
              "uniqueItems": true
            }
          },
          "required": ["services"],
          "additionalProperties": false
        },
        "clients": {
          "type": "object",
          "properties": {
            "default-node-version": {
              "type": "string",
              "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
            },
            "default-nginx-version": {
              "type": "string",
              "pattern": "^[0-9]+\\.[0-9]+-alpine$"
            },
            "clients": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "web-app",
                  "desktop-app"
                ]
              },
              "uniqueItems": true
            }
          },
          "required": ["clients"],
          "additionalProperties": false
        }
      },
      "required": ["services", "infrastructure", "clients"],
      "additionalProperties": false
    },
    "environment-mapping": {
      "type": "object",
      "description": "Maps internal version names to environment variable names",
      "properties": {
        "gradle-version": {
          "type": "string",
          "enum": ["DOCKER_GRADLE_VERSION"]
        },
        "java-version": {
          "type": "string",
          "enum": ["DOCKER_JAVA_VERSION"]
        },
        "node-version": {
          "type": "string",
          "enum": ["DOCKER_NODE_VERSION"]
        },
        "nginx-version": {
          "type": "string",
          "enum": ["DOCKER_NGINX_VERSION"]
        },
        "prometheus-version": {
          "type": "string",
          "enum": ["DOCKER_PROMETHEUS_VERSION"]
        },
        "grafana-version": {
          "type": "string",
          "enum": ["DOCKER_GRAFANA_VERSION"]
        },
        "keycloak-version": {
          "type": "string",
          "enum": ["DOCKER_KEYCLOAK_VERSION"]
        },
        "spring-profiles-default": {
          "type": "string",
          "enum": ["DOCKER_SPRING_PROFILES_DEFAULT"]
        },
        "spring-profiles-docker": {
          "type": "string",
          "enum": ["DOCKER_SPRING_PROFILES_DOCKER"]
        },
        "app-version": {
          "type": "string",
          "enum": ["DOCKER_APP_VERSION"]
        }
      },
      "required": [
        "gradle-version",
        "java-version",
        "node-version",
        "nginx-version",
        "prometheus-version",
        "grafana-version",
        "keycloak-version",
        "app-version"
      ],
      "additionalProperties": false
    },
    "environments": {
      "type": "object",
      "description": "Environment-specific configurations",
      "properties": {
        "development": {
          "$ref": "#/definitions/environment-config"
        },
        "production": {
          "$ref": "#/definitions/environment-config"
        },
        "testing": {
          "$ref": "#/definitions/environment-config"
        }
      },
      "required": ["development", "production", "testing"],
      "additionalProperties": false
    }
  },
  "required": [
    "versions",
    "service-ports",
    "port-ranges",
    "build-args",
    "categories",
    "environment-mapping",
    "environments"
  ],
  "additionalProperties": false,
  "definitions": {
    "environment-config": {
      "type": "object",
      "description": "Environment-specific configuration settings",
      "properties": {
        "spring-profiles": {
          "type": "string",
          "enum": ["dev", "test", "prod", "docker"],
          "description": "Default Spring profiles for this environment"
        },
        "debug-enabled": {
          "type": "boolean",
          "description": "Whether debug mode is enabled"
        },
        "log-level": {
          "type": "string",
          "enum": ["TRACE", "DEBUG", "INFO", "WARN", "ERROR"],
          "description": "Default log level for services"
        },
        "health-check-interval": {
          "type": "string",
          "pattern": "^[0-9]+s$",
          "description": "Health check interval (e.g., '30s')"
        },
        "health-check-timeout": {
          "type": "string",
          "pattern": "^[0-9]+s$",
          "description": "Health check timeout (e.g., '5s')"
        },
        "health-check-retries": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10,
          "description": "Number of health check retries"
        },
        "health-check-start-period": {
          "type": "string",
          "pattern": "^[0-9]+s$",
          "description": "Health check start period (e.g., '40s')"
        },
        "resource-limits": {
          "type": "boolean",
          "description": "Whether to enforce resource limits"
        },
        "jvm-debug-port": {
          "oneOf": [
            {
              "type": "integer",
              "minimum": 5005,
              "maximum": 5009
            },
            {
              "type": "boolean",
              "enum": [false]
            }
          ],
          "description": "JVM debug port (5005-5009) or false to disable"
        },
        "hot-reload": {
          "type": "boolean",
          "description": "Whether hot reload is enabled for development"
        },
        "security-headers": {
          "type": "boolean",
          "description": "Whether to add security headers (production)"
        },
        "tls-enabled": {
          "type": "boolean",
          "description": "Whether TLS/SSL is enabled (production)"
        },
        "ephemeral-storage": {
          "type": "boolean",
          "description": "Whether to use ephemeral storage (testing)"
        },
        "test-containers": {
          "type": "boolean",
          "description": "Whether test containers are used (testing)"
        }
      },
      "required": [
        "spring-profiles",
        "debug-enabled",
        "log-level",
        "health-check-interval",
        "health-check-timeout",
        "health-check-retries",
        "health-check-start-period",
        "resource-limits",
        "jvm-debug-port",
        "hot-reload"
      ],
      "additionalProperties": false
    }
  }
}
