{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/railway/latest.json",
  "x-lintel": {
    "source": "https://railway.com/railway.schema.json",
    "sourceSha256": "38d35a7de8d6fa511895abbcf9a2cac49a12494fd6a9cd2d4228a5b2a8af5e5f",
    "fileMatch": [
      "railway.toml",
      "railway.json"
    ],
    "parsers": [
      "json",
      "toml"
    ]
  },
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "build": {
      "type": "object",
      "properties": {
        "builder": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "NIXPACKS",
                "DOCKERFILE",
                "RAILPACK",
                "HEROKU",
                "PAKETO"
              ],
              "description": "Set the builder for the deployment"
            },
            {
              "type": "null"
            }
          ]
        },
        "watchPatterns": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string",
                "description": "Array of patterns used to conditionally trigger a deploys"
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "buildCommand": {
          "type": [
            "string",
            "null"
          ]
        },
        "dockerfilePath": {
          "type": [
            "string",
            "null"
          ]
        },
        "nixpacksConfigPath": {
          "type": [
            "string",
            "null"
          ]
        },
        "nixpacksPlan": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "providers": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "List of language providers to build the app with"
                },
                "phases": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "dependsOn": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "cmds": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "nixPkgs": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "nixLibs": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "aptPkgs": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "nixOverlays": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "nixPkgsArchive": {
                        "type": "string"
                      },
                      "includedFiles": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "cacheDirectories": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "paths": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "description": "Single Nixpacks phase",
                    "additionalProperties": false
                  }
                }
              },
              "description": "Full nixpacks plan. See <https://nixpacks.com/docs/configuration/file> for more info",
              "additionalProperties": true
            },
            {
              "type": "null"
            }
          ]
        },
        "nixpacksVersion": {
          "type": [
            "string",
            "null"
          ]
        },
        "railpackVersion": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "description": "Configuration for the build step",
      "additionalProperties": false
    },
    "deploy": {
      "type": "object",
      "properties": {
        "startCommand": {
          "type": [
            "string",
            "null"
          ]
        },
        "preDeployCommand": {
          "anyOf": [
            {
              "anyOf": [
                {
                  "not": {}
                },
                {
                  "anyOf": [
                    {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "maxItems": 1
                        }
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "numReplicas": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "The number of instances to run for the deployment"
            },
            {
              "type": "null"
            }
          ]
        },
        "healthcheckPath": {
          "type": [
            "string",
            "null"
          ]
        },
        "healthcheckTimeout": {
          "type": [
            "number",
            "null"
          ]
        },
        "sleepApplication": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "runtime": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "UNSPECIFIED",
                "LEGACY",
                "V2"
              ],
              "description": "Runtime to use for the deployment"
            },
            {
              "type": "null"
            }
          ]
        },
        "registryCredentials": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "username": {
                  "type": "string"
                },
                "password": {
                  "type": "string"
                }
              },
              "description": "Private Docker registry credentials. Only available for Pro plan deployments.",
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "restartPolicyType": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "ON_FAILURE",
                "ALWAYS",
                "NEVER"
              ],
              "description": "How to handle the deployment crashing"
            },
            {
              "type": "null"
            }
          ]
        },
        "restartPolicyMaxRetries": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "cronSchedule": {
          "type": [
            "string",
            "null"
          ]
        },
        "region": {
          "type": [
            "string",
            "null"
          ]
        },
        "multiRegionConfig": {
          "anyOf": [
            {
              "type": "object",
              "description": "Multi-region deployment configuration",
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "numReplicas": {
                        "anyOf": [
                          {
                            "$ref": "#/properties/deploy/properties/numReplicas/anyOf/0"
                          },
                          {
                            "type": "null"
                          }
                        ],
                        "description": "The number of instances to run for the deployment"
                      },
                      "stackerAssignment": {
                        "anyOf": [
                          {
                            "anyOf": [
                              {
                                "type": "string",
                                "pattern": "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",
                                "description": "IP of the stacker to assign the deployment to"
                              },
                              {
                                "type": "string",
                                "const": "ALL_STACKERS",
                                "description": "Assign to all stackers in the region"
                              }
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "limitOverride": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "containers": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "cpu": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "memoryBytes": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "diskBytes": {
                          "type": [
                            "number",
                            "null"
                          ]
                        }
                      },
                      "description": "Container limits",
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "description": "Resource limits available",
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "requiredMountPath": {
          "type": [
            "string",
            "null"
          ]
        },
        "overlapSeconds": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "description": "Time in seconds that the previous deploy will overlap with the newest one being deployed"
            },
            {
              "type": "null"
            }
          ]
        },
        "drainingSeconds": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0,
              "description": "The time in seconds between when the previous deploy is sent a SIGTERM to the time it is sent a SIGKILL"
            },
            {
              "type": "null"
            }
          ]
        },
        "ipv6EgressEnabled": {
          "type": [
            "boolean",
            "null"
          ]
        }
      },
      "description": "Configuration for the deploy step",
      "additionalProperties": false
    },
    "environments": {
      "type": "object",
      "description": "Override service manifest for different environments",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "build": {
            "type": "object",
            "properties": {
              "builder": {
                "anyOf": [
                  {
                    "$ref": "#/properties/build/properties/builder/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "watchPatterns": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/properties/build/properties/watchPatterns/anyOf/0/items"
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "buildCommand": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "buildEnvironment": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "V2",
                      "V3"
                    ],
                    "description": "Build environment to be used for the build process"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "dockerfilePath": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "nixpacksConfigPath": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "nixpacksPlan": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "providers": {
                        "type": "array",
                        "items": {
                          "$ref": "#/properties/build/properties/nixpacksPlan/anyOf/0/properties/providers/items"
                        },
                        "description": "List of language providers to build the app with"
                      },
                      "phases": {
                        "$ref": "#/properties/build/properties/nixpacksPlan/anyOf/0/properties/phases"
                      }
                    },
                    "description": "Full nixpacks plan. See <https://nixpacks.com/docs/configuration/file> for more info",
                    "additionalProperties": true
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "nixpacksVersion": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "railpackVersion": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "Configuration for the build step",
            "additionalProperties": false
          },
          "deploy": {
            "type": "object",
            "properties": {
              "startCommand": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "preDeployCommand": {
                "anyOf": [
                  {
                    "$ref": "#/properties/deploy/properties/preDeployCommand/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "numReplicas": {
                "anyOf": [
                  {
                    "$ref": "#/properties/deploy/properties/numReplicas/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "healthcheckPath": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "healthcheckTimeout": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "sleepApplication": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "runtime": {
                "anyOf": [
                  {
                    "$ref": "#/properties/deploy/properties/runtime/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "registryCredentials": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "username": {
                        "$ref": "#/properties/deploy/properties/registryCredentials/anyOf/0/properties/username"
                      },
                      "password": {
                        "$ref": "#/properties/deploy/properties/registryCredentials/anyOf/0/properties/password"
                      }
                    },
                    "description": "Private Docker registry credentials. Only available for Pro plan deployments.",
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "restartPolicyType": {
                "anyOf": [
                  {
                    "$ref": "#/properties/deploy/properties/restartPolicyType/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "restartPolicyMaxRetries": {
                "anyOf": [
                  {
                    "$ref": "#/properties/deploy/properties/restartPolicyMaxRetries/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "cronSchedule": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "region": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "multiRegionConfig": {
                "anyOf": [
                  {
                    "$ref": "#/properties/deploy/properties/multiRegionConfig/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "limitOverride": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "containers": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "cpu": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "memoryBytes": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "diskBytes": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              }
                            },
                            "description": "Container limits",
                            "additionalProperties": false
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "description": "Resource limits available",
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "requiredMountPath": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "overlapSeconds": {
                "anyOf": [
                  {
                    "$ref": "#/properties/deploy/properties/overlapSeconds/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "drainingSeconds": {
                "anyOf": [
                  {
                    "$ref": "#/properties/deploy/properties/drainingSeconds/anyOf/0"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "useLegacyStacker": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "ipv6EgressEnabled": {
                "type": [
                  "boolean",
                  "null"
                ]
              }
            },
            "description": "Configuration for the deploy step",
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
