{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/platform-sh-application/latest.json",
  "title": "Platform.sh application configuration file",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/platformsh/platformify/refs/heads/main/validator/schema/platformsh.application.json",
    "sourceSha256": "d0b35278902a39c39e96514d066461e0703d59f0edfc84b21dc0fa53fb90d27f",
    "fileMatch": [
      ".platform.app.yml",
      ".platform.app.yaml",
      "**/.platform.app.yml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "resources": {
      "type": "object",
      "properties": {
        "base_memory": {
          "type": "integer",
          "title": "The base memory for the container",
          "default": 64
        },
        "memory_ratio": {
          "type": "integer",
          "title": "The amount of memory to allocate per units of CPU",
          "default": 128
        }
      },
      "default": null,
      "nullable": true,
      "title": "Resources",
      "additionalProperties": false
    },
    "size": {
      "type": "string",
      "title": "The container size for this application in production. Leave blank to allow it to be set dynamically.",
      "default": "AUTO"
    },
    "disk": {
      "type": "integer",
      "title": "The writeable disk size to reserve on this application container.",
      "default": null
    },
    "access": {
      "type": "object",
      "default": {
        "ssh": "contributor"
      },
      "title": "Access information, a mapping between access type and roles.",
      "additionalProperties": {
        "type": "string"
      }
    },
    "relationships": {
      "type": "object",
      "default": {},
      "title": "The relationships of the application to defined services.",
      "additionalProperties": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          },
          {
            "type": "object",
            "properties": {
              "service": {
                "type": "string"
              },
              "endpoint": {
                "type": "string"
              }
            }
          }
        ]
      }
    },
    "mounts": {
      "type": "object",
      "default": {},
      "title": "Filesystem mounts of this application.  If not specified the application will have no writeable disk space.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "title": "The type of mount that will provide the data.",
            "enum": [
              "local",
              "service",
              "tmp"
            ]
          },
          "source_path": {
            "type": "string",
            "title": "The path to be mounted, relative to the root directory of the volume that's being mounted from."
          },
          "service": {
            "type": "string",
            "title": "The name of the service that the volume will be mounted from. Must be a service in `services.yaml` of type `network-storage`."
          }
        },
        "required": [
          "source"
        ],
        "additionalProperties": false
      }
    },
    "timezone": {
      "type": "string",
      "title": "The timezone of the application.  This primarily affects the timezone in which cron tasks will run.  It will not affect the application itself. Defaults to UTC if not specified.",
      "default": null
    },
    "variables": {
      "type": "object",
      "default": {},
      "title": "Variables provide environment-sensitive information to control how your application behaves.  To set a Unix environment variable, specify a key of `env:`, and then each sub-item of that is a key/value pair that will be injected into the environment.",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": {}
      }
    },
    "firewall": {
      "type": "object",
      "properties": {
        "outbound": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "protocol": {
                "type": "string",
                "title": "The IP protocol to apply the restriction on.",
                "default": "tcp"
              },
              "ips": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "title": "The IP range in CIDR notation to apply the restriction on.",
                "default": []
              },
              "domains": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "title": "Domains of the restriction.",
                "default": []
              },
              "ports": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "title": "The port to apply the restriction on.",
                "default": []
              }
            },
            "additionalProperties": false
          },
          "title": "Outbound firewall restrictions",
          "default": []
        }
      },
      "default": null,
      "nullable": true,
      "title": "Firewall",
      "additionalProperties": false
    },
    "name": {
      "type": "string",
      "title": "The name of the application. Must be unique within a project."
    },
    "type": {
      "type": "string",
      "title": "The base runtime (language) and version to use for this application."
    },
    "runtime": {
      "type": "object",
      "title": "Runtime-specific configuration.",
      "default": {}
    },
    "preflight": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "title": "Whether the preflight security blocks are enabled."
        },
        "ignored_rules": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "title": "Specific rules to ignore during preflight security checks. See the documentation for options.",
          "default": []
        }
      },
      "required": [
        "enabled"
      ],
      "default": {
        "enabled": true,
        "ignored_rules": []
      },
      "title": "Configuration for pre-flight checks.",
      "additionalProperties": false
    },
    "dependencies": {
      "type": "object",
      "default": {},
      "title": "External global dependencies of this application. They will be downloaded by the language's package manager.",
      "additionalProperties": {
        "type": "object"
      }
    },
    "build": {
      "type": "object",
      "properties": {
        "flavor": {
          "type": "string",
          "title": "The pre-set build tasks to use for this application.",
          "default": null
        },
        "caches": {
          "type": "object",
          "default": {},
          "title": "The configuration of paths managed by the build cache.",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "directory": {
                "type": "string",
                "title": "The directory, relative to the application root, that should be cached.",
                "default": null
              },
              "watch": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "title": "The file or files whose hashed contents should be considered part of the cache key."
              },
              "allow_stale": {
                "type": "boolean",
                "title": "If true, on a cache miss the last cache version will be used and can be updated in place.",
                "default": false
              },
              "share_between_apps": {
                "type": "boolean",
                "title": "Whether multiple applications in the project should share cached directories.",
                "default": false
              }
            },
            "required": [
              "watch"
            ],
            "additionalProperties": false
          }
        }
      },
      "default": {
        "flavor": null,
        "caches": {}
      },
      "title": "The build configuration of the application.",
      "additionalProperties": false
    },
    "source": {
      "type": "object",
      "properties": {
        "root": {
          "type": "string",
          "title": "The root of the application relative to the repository root.",
          "default": null
        },
        "operations": {
          "type": "object",
          "default": {},
          "title": "Operations that can be applied to the source code.",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "command": {
                "type": "string",
                "title": "The command to use to update this application."
              }
            },
            "required": [
              "command"
            ],
            "additionalProperties": false
          }
        }
      },
      "default": {
        "operations": {},
        "root": null
      },
      "title": "Configuration related to the source code of the application.",
      "additionalProperties": false
    },
    "web": {
      "type": "object",
      "properties": {
        "firewall": {
          "type": "object",
          "properties": {
            "outbound": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "protocol": {
                    "type": "string",
                    "title": "The IP protocol to apply the restriction on.",
                    "default": "tcp"
                  },
                  "ips": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "title": "The IP range in CIDR notation to apply the restriction on.",
                    "default": []
                  },
                  "domains": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "title": "Domains of the restriction.",
                    "default": []
                  },
                  "ports": {
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "title": "The port to apply the restriction on.",
                    "default": []
                  }
                },
                "additionalProperties": false
              },
              "title": "Outbound firewall restrictions",
              "default": []
            }
          },
          "title": "Firewall",
          "nullable": true,
          "additionalProperties": false
        },
        "variables": {
          "type": "object",
          "title": "Variables provide environment-sensitive information to control how your application behaves.  To set a Unix environment variable, specify a key of `env:`, and then each sub-item of that is a key/value pair that will be injected into the environment.",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": {}
          }
        },
        "timezone": {
          "type": "string",
          "title": "The timezone of the application.  This primarily affects the timezone in which cron tasks will run.  It will not affect the application itself. Defaults to UTC if not specified."
        },
        "mounts": {
          "type": "object",
          "title": "Filesystem mounts of this application.  If not specified the application will have no writeable disk space.",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "source": {
                "type": "string",
                "title": "The type of mount that will provide the data.",
                "enum": [
                  "local",
                  "service",
                  "tmp"
                ]
              },
              "source_path": {
                "type": "string",
                "title": "The path to be mounted, relative to the root directory of the volume that's being mounted from."
              },
              "service": {
                "type": "string",
                "title": "The name of the service that the volume will be mounted from. Must be a service in `services.yaml` of type `network-storage`."
              }
            },
            "required": [
              "source"
            ],
            "additionalProperties": false
          }
        },
        "relationships": {
          "type": "object",
          "default": {},
          "title": "The relationships of the application to defined services.",
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              },
              {
                "type": "object",
                "properties": {
                  "service": {
                    "type": "string"
                  },
                  "endpoint": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "access": {
          "type": "object",
          "title": "Access information, a mapping between access type and roles.",
          "additionalProperties": {
            "type": "string"
          }
        },
        "disk": {
          "type": "integer",
          "title": "The writeable disk size to reserve on this application container."
        },
        "size": {
          "type": "string",
          "title": "The container size for this application in production. Leave blank to allow it to be set dynamically."
        },
        "resources": {
          "type": "object",
          "properties": {
            "base_memory": {
              "type": "integer",
              "title": "The base memory for the container",
              "default": 64
            },
            "memory_ratio": {
              "type": "integer",
              "title": "The amount of memory to allocate per units of CPU",
              "default": 128
            }
          },
          "title": "Resources",
          "nullable": true,
          "additionalProperties": false
        },
        "locations": {
          "type": "object",
          "default": {},
          "title": "The specification of the web locations served by this application.",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "root": {
                "type": "string",
                "title": "The folder from which to serve static assets for this location relative to the application root.",
                "default": null
              },
              "expires": {
                "type": [
                  "integer",
                  "string"
                ],
                "title": "Amount of time to cache static assets.",
                "default": -1
              },
              "passthru": {
                "type": [
                  "string",
                  "boolean"
                ],
                "title": "Whether to forward disallowed and missing resources from this location to the application. On PHP, set to the PHP front controller script, as a URL fragment. Otherwise set to `true`/`false`.",
                "default": true
              },
              "scripts": {
                "type": "boolean",
                "title": "Whether to execute scripts in this location (for script based runtimes).",
                "default": true
              },
              "index": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "title": "Files to look for to serve directories."
              },
              "allow": {
                "type": "boolean",
                "title": "Whether to allow access to this location by default.",
                "default": true
              },
              "headers": {
                "type": "object",
                "default": {},
                "title": "A set of header fields set to the HTTP response. Applies only to static files, not responses from the application.",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "rules": {
                "type": "object",
                "default": {},
                "title": "Specific overrides.",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "expires": {
                      "type": [
                        "integer",
                        "string"
                      ],
                      "title": "Amount of time to cache static assets."
                    },
                    "passthru": {
                      "type": "string",
                      "title": "Whether to forward disallowed and missing resources from this location to the application. On PHP, set to the PHP front controller script, as a URL fragment. Otherwise set to `true`/`false`."
                    },
                    "scripts": {
                      "type": "boolean",
                      "title": "Whether to execute scripts in this location (for script based runtimes)."
                    },
                    "allow": {
                      "type": "boolean",
                      "title": "Whether to allow access to this location by default."
                    },
                    "headers": {
                      "type": "object",
                      "title": "A set of header fields set to the HTTP response. Replaces headers set on the location block.",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  },
                  "additionalProperties": false
                }
              },
              "request_buffering": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean",
                    "title": "Enable request buffering.",
                    "default": true
                  },
                  "max_request_size": {
                    "type": "string",
                    "title": "The maximum size request that can be buffered. Supports K, M, and G suffixes.",
                    "default": 262144000
                  }
                },
                "title": "Configuration for supporting request buffering.",
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          }
        },
        "commands": {
          "type": "object",
          "properties": {
            "pre_start": {
              "type": "string",
              "title": "The command used to run before starting the application."
            },
            "start": {
              "type": "string",
              "title": "The command used to start the application.  It will be restarted if it terminates. Do not use on PHP unless using a custom persistent process like React PHP."
            },
            "post_start": {
              "type": "string",
              "title": "A command executed after the application is started."
            }
          },
          "required": [
            "start"
          ],
          "title": "Commands to manage the application's lifecycle.",
          "additionalProperties": false
        },
        "upstream": {
          "type": "object",
          "properties": {
            "socket_family": {
              "type": "string",
              "title": "If `tcp`, check the PORT environment variable on application startup. If `unix`, check SOCKET.",
              "default": "tcp"
            },
            "protocol": {
              "type": "string",
              "title": "Protocol",
              "default": null
            }
          },
          "title": "Configuration on how the web server communicates with the application.",
          "additionalProperties": false
        },
        "document_root": {
          "type": "string",
          "title": "The document root of this application, relative to its root."
        },
        "passthru": {
          "type": "string",
          "title": "The URL to use as a passthru if a file doesn't match the whitelist."
        },
        "index_files": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "title": "Files to look for to serve directories."
        },
        "whitelist": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "title": "Whitelisted entries."
        },
        "blacklist": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "title": "Blacklisted entries."
        },
        "expires": {
          "type": [
            "integer",
            "string"
          ],
          "title": "Amount of time to cache static assets."
        },
        "move_to_root": {
          "type": "boolean",
          "title": "Whether to move the whole root of the app to the document root.",
          "default": false
        }
      },
      "default": {
        "locations": {}
      },
      "title": "Configuration for accessing this application via HTTP.",
      "additionalProperties": false
    },
    "hooks": {
      "type": "object",
      "properties": {
        "build": {
          "type": "string",
          "title": "Hook executed after the build process.",
          "default": null
        },
        "deploy": {
          "type": "string",
          "title": "Hook executed after the deployment of new code.",
          "default": null
        },
        "post_deploy": {
          "type": "string",
          "title": "Hook executed after an environment is fully deployed.",
          "default": null
        }
      },
      "default": {},
      "title": "Scripts executed at various points in the lifecycle of the application.",
      "additionalProperties": false
    },
    "crons": {
      "type": "object",
      "default": {},
      "title": "Scheduled cron tasks executed by this application.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "spec": {
            "type": "string",
            "title": "The cron schedule specification."
          },
          "commands": {
            "type": "object",
            "properties": {
              "start": {
                "type": "string",
                "title": "The command used to start the cron job."
              },
              "stop": {
                "type": "string",
                "title": "The command used to stop the cron job.",
                "default": null
              }
            },
            "required": [
              "start"
            ],
            "title": "The start and stop commands definition.",
            "additionalProperties": false
          },
          "shutdown_timeout": {
            "type": "integer",
            "title": "The timeout in seconds after which the cron job will be forcefully killed.",
            "default": null
          },
          "cmd": {
            "type": "string",
            "title": "The command to execute."
          }
        },
        "required": [
          "spec"
        ],
        "additionalProperties": false
      }
    },
    "workers": {
      "type": "object",
      "default": {},
      "title": "Persistent worker containers created by this application.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "firewall": {
            "type": "object",
            "properties": {
              "outbound": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "protocol": {
                      "type": "string",
                      "title": "The IP protocol to apply the restriction on.",
                      "default": "tcp"
                    },
                    "ips": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "title": "The IP range in CIDR notation to apply the restriction on.",
                      "default": []
                    },
                    "domains": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "title": "Domains of the restriction.",
                      "default": []
                    },
                    "ports": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      },
                      "title": "The port to apply the restriction on.",
                      "default": []
                    }
                  },
                  "additionalProperties": false
                },
                "title": "Outbound firewall restrictions",
                "default": []
              }
            },
            "title": "Firewall",
            "nullable": true,
            "additionalProperties": false
          },
          "variables": {
            "type": "object",
            "title": "Variables provide environment-sensitive information to control how your application behaves.  To set a Unix environment variable, specify a key of `env:`, and then each sub-item of that is a key/value pair that will be injected into the environment.",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {}
            }
          },
          "timezone": {
            "type": "string",
            "title": "The timezone of the application.  This primarily affects the timezone in which cron tasks will run.  It will not affect the application itself. Defaults to UTC if not specified."
          },
          "mounts": {
            "type": "object",
            "title": "Filesystem mounts of this application.  If not specified the application will have no writeable disk space.",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "source": {
                  "type": "string",
                  "title": "The type of mount that will provide the data.",
                  "enum": [
                    "local",
                    "service",
                    "tmp"
                  ]
                },
                "source_path": {
                  "type": "string",
                  "title": "The path to be mounted, relative to the root directory of the volume that's being mounted from."
                },
                "service": {
                  "type": "string",
                  "title": "The name of the service that the volume will be mounted from. Must be a service in `services.yaml` of type `network-storage`."
                }
              },
              "required": [
                "source"
              ],
              "additionalProperties": false
            }
          },
          "relationships": {
            "type": "object",
            "default": {},
            "title": "The relationships of the application to defined services.",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                },
                {
                  "type": "object",
                  "properties": {
                    "service": {
                      "type": "string"
                    },
                    "endpoint": {
                      "type": "string"
                    }
                  }
                }
              ]
            }
          },
          "access": {
            "type": "object",
            "title": "Access information, a mapping between access type and roles.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "disk": {
            "type": "integer",
            "title": "The writeable disk size to reserve on this application container."
          },
          "size": {
            "type": "string",
            "title": "The container size for this application in production. Leave blank to allow it to be set dynamically."
          },
          "resources": {
            "type": "object",
            "properties": {
              "base_memory": {
                "type": "integer",
                "title": "The base memory for the container",
                "default": 64
              },
              "memory_ratio": {
                "type": "integer",
                "title": "The amount of memory to allocate per units of CPU",
                "default": 128
              }
            },
            "title": "Resources",
            "nullable": true,
            "additionalProperties": false
          },
          "commands": {
            "type": "object",
            "properties": {
              "pre_start": {
                "type": "string",
                "title": "The command used to run before starting the cron job."
              },
              "start": {
                "type": "string",
                "title": "The command used to start the application.  It will be restarted if it terminates. Do not use on PHP unless using a custom persistent process like React PHP."
              }
            },
            "required": [
              "start"
            ],
            "title": "The commands to manage the worker.",
            "additionalProperties": false
          }
        },
        "required": [
          "commands"
        ],
        "additionalProperties": false
      }
    },
    "additional_hosts": {
      "type": "object",
      "title": "Resolve additional IPs to domain names.",
      "additionalProperties": {
        "type": "string"
      }
    },
    "stack": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object"
        },
        {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object"
              }
            ]
          }
        }
      ]
    }
  },
  "additionalProperties": false,
  "oneOf": [
    {
      "required": [
        "name",
        "type"
      ]
    },
    {
      "required": [
        "name",
        "stack"
      ]
    }
  ]
}
