{
  "manifest_version": "1.0.0",
  "template": {
    "id": "31ae0705-f6a2-4d6d-8041-75c7d71d1936",
    "slug": "spicedb-with-postgresql",
    "name": "SpiceDB with PostgreSQL",
    "description": "Relationship authorization with PostgreSQL and authenticated API access.",
    "url": "https://railway.com/deploy/spicedb-with-postgresql",
    "upstream": {
      "repo_url": "https://github.com/orenaksakal/railway-templates"
    }
  },
  "services": [
    {
      "name": "postgres",
      "source": {
        "image": "postgres:17@sha256:67f41722b7a8cbdb868a44a4995c846eddfdc2973bccb291ce937dce88ad5675"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": false
    },
    {
      "name": "spicedb",
      "source": {
        "repo": "https://github.com/orenaksakal/railway-templates"
      },
      "needs_volume": false,
      "http": true
    }
  ],
  "required_inputs": [
    {
      "key": "PGDATA",
      "service": "postgres",
      "description": "PostgreSQL data directory within the persistent volume. Do not change on an existing database.",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "POSTGRES_DB",
      "service": "postgres",
      "description": "Initial PostgreSQL database name, or the matching database selected by the application.",
      "secret": false,
      "strategy": "default",
      "default": "spicedb"
    },
    {
      "key": "DATABASE_URL",
      "service": "postgres",
      "description": "Private PostgreSQL connection URL assembled from generated credentials and service references. No manual value is needed.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "postgres",
      "description": "PostgreSQL initialization user, or the matching connection user for the private database.",
      "secret": false,
      "strategy": "default",
      "default": "spicedb"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "postgres",
      "description": "PostgreSQL password. Generated for the database and referenced by dependent services; keep private.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "SPICEDB_GRPC_ADDR",
      "service": "spicedb",
      "description": "Private authenticated gRPC listener. No public TCP proxy is created.",
      "secret": false,
      "strategy": "default",
      "default": "[::]:50051"
    },
    {
      "key": "SPICEDB_HTTP_ADDR",
      "service": "spicedb",
      "description": "HTTP gateway listener; Railway terminates public TLS.",
      "secret": false,
      "strategy": "default",
      "default": "[::]:8443"
    },
    {
      "key": "SPICEDB_HTTP_ENABLED",
      "service": "spicedb",
      "description": "Enable the authenticated HTTP gateway for Railway HTTPS access.",
      "secret": false,
      "strategy": "default",
      "default": "true"
    },
    {
      "key": "RAILWAY_DOCKERFILE_PATH",
      "service": "spicedb",
      "description": "Repository-relative Dockerfile used to build this service. Keep the supplied path.",
      "secret": false,
      "strategy": "default",
      "default": "templates/spicedb/Dockerfile"
    },
    {
      "key": "SPICEDB_DATASTORE_ENGINE",
      "service": "spicedb",
      "description": "Use the included PostgreSQL datastore.",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SPICEDB_DATASTORE_CONN_URI",
      "service": "spicedb",
      "description": "Spicedb datastore conn uri resolved automatically from the linked service. Keep this reference when using the included topology.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SPICEDB_GRPC_PRESHARED_KEY",
      "service": "spicedb",
      "description": "Generated spicedb grpc preshared key. Keep private and preserve with backups.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "spicedb-with-postgresql"
      }
    },
    "cli": "railway deploy --template spicedb-with-postgresql",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "31ae0705-f6a2-4d6d-8041-75c7d71d1936",
            "serializedConfig": {
              "services": {
                "3e18d657-8583-5a15-b68b-9563b1bc4013": {
                  "name": "postgres",
                  "deploy": {
                    "requiredMountPath": "/var/lib/postgresql/data",
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "postgres:17@sha256:67f41722b7a8cbdb868a44a4995c846eddfdc2973bccb291ce937dce88ad5675"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "PostgreSQL data directory within the persistent volume. Do not change on an existing database.",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Initial PostgreSQL database name, or the matching database selected by the application.",
                      "defaultValue": "spicedb"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "Private PostgreSQL connection URL assembled from generated credentials and service references. No manual value is needed.",
                      "defaultValue": "postgresql://spicedb:${{postgres.POSTGRES_PASSWORD}}@${{postgres.RAILWAY_PRIVATE_DOMAIN}}:5432/spicedb"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "PostgreSQL initialization user, or the matching connection user for the private database.",
                      "defaultValue": "spicedb"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "PostgreSQL password. Generated for the database and referenced by dependent services; keep private.",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    }
                  },
                  "networking": {
                    "serviceDomains": {}
                  },
                  "volumeMounts": {
                    "fce22db3-b075-5a94-ba1f-d1525bbeaff1": {
                      "mountPath": "/var/lib/postgresql/data"
                    }
                  }
                },
                "f40fd2d0-83ed-57be-8bb6-64e3333a8f8e": {
                  "name": "spicedb",
                  "build": {
                    "builder": "RAILPACK",
                    "dockerfilePath": "templates/spicedb/Dockerfile"
                  },
                  "deploy": {
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "repo": "orenaksakal/railway-templates",
                    "branch": "codex/remaining-template-drafts"
                  },
                  "variables": {
                    "SPICEDB_GRPC_ADDR": {
                      "isOptional": false,
                      "description": "Private authenticated gRPC listener. No public TCP proxy is created.",
                      "defaultValue": "[::]:50051"
                    },
                    "SPICEDB_HTTP_ADDR": {
                      "isOptional": false,
                      "description": "HTTP gateway listener; Railway terminates public TLS.",
                      "defaultValue": "[::]:8443"
                    },
                    "SPICEDB_HTTP_ENABLED": {
                      "isOptional": false,
                      "description": "Enable the authenticated HTTP gateway for Railway HTTPS access.",
                      "defaultValue": "true"
                    },
                    "RAILWAY_DOCKERFILE_PATH": {
                      "isOptional": false,
                      "description": "Repository-relative Dockerfile used to build this service. Keep the supplied path.",
                      "defaultValue": "templates/spicedb/Dockerfile"
                    },
                    "SPICEDB_DATASTORE_ENGINE": {
                      "isOptional": false,
                      "description": "Use the included PostgreSQL datastore.",
                      "defaultValue": "postgres"
                    },
                    "SPICEDB_DATASTORE_CONN_URI": {
                      "isOptional": false,
                      "description": "Spicedb datastore conn uri resolved automatically from the linked service. Keep this reference when using the included topology.",
                      "defaultValue": "${{postgres.DATABASE_URL}}?sslmode=disable"
                    },
                    "SPICEDB_GRPC_PRESHARED_KEY": {
                      "isOptional": false,
                      "description": "Generated spicedb grpc preshared key. Keep private and preserve with backups.",
                      "defaultValue": "{{SPICEDB_GRPC_PRESHARED_KEY}}"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>:8443": {
                        "port": 8443
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {},
  "resources": {
    "expected_services": 2,
    "needs_volume": true
  },
  "generated_at": "2026-09-08T05:54:19.399Z",
  "generator_version": "0.1.0",
  "status": "validated",
  "validated_at": "2026-09-08T05:59:11.750Z",
  "success_rate_30d": 1,
  "validation": {
    "last_run_id": "run_355181a803084c128211",
    "checks": [
      {
        "name": "workflow_completed",
        "passed": true
      },
      {
        "name": "all_services_deployed",
        "passed": true
      },
      {
        "name": "stays_up",
        "passed": true
      }
    ],
    "typical_ready_seconds": 28,
    "typical_build_seconds": 10,
    "typical_start_seconds": 0,
    "slowest_service": "spicedb"
  }
}
