{
  "manifest_version": "1.0.0",
  "template": {
    "id": "67c29a1a-e869-448e-bc42-252d66f82be5",
    "slug": "pgdog-with-postgres",
    "name": "PgDog with Postgres",
    "description": "A high-performance PostgreSQL proxy with pooling, routing, and sharding.",
    "url": "https://railway.com/deploy/pgdog-with-postgres"
  },
  "services": [
    {
      "name": "Postgres-Shard-1",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": false
    },
    {
      "name": "pgdog",
      "source": {
        "image": "ghcr.io/pgdogdev/pgdog:v0.1.48"
      },
      "needs_volume": false,
      "tcp_ports": [
        6432
      ],
      "http": false
    },
    {
      "name": "Postgres-Shard-0",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": false
    }
  ],
  "required_inputs": [
    {
      "key": "PGDATA",
      "service": "Postgres-Shard-1",
      "description": "Location where the database will be initialized",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "Postgres-Shard-1",
      "description": "Railway Private Domain Name.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "Postgres-Shard-1",
      "description": "Port to connect to Postgres.",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "Postgres-Shard-1",
      "description": "Required variable for Data panel",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "Postgres-Shard-1",
      "description": "Required variable for the data panel.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "Postgres-Shard-1",
      "description": "Required variable for Data panel",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres-Shard-1",
      "description": "Default database created when image is started.",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "Postgres-Shard-1",
      "description": "URL to connect to Postgres database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres-Shard-1",
      "description": "User to connect to Postgres DB",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "Postgres-Shard-1",
      "description": "SSL certificate expiry in days.",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres-Shard-1",
      "description": "Password to connect to DB",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres-Shard-1",
      "description": "Allow Postgres to cleanly shut down",
      "secret": false,
      "strategy": "default",
      "default": "60"
    },
    {
      "key": "RUST_LOG",
      "service": "pgdog",
      "description": "PgDog logging level",
      "secret": false,
      "strategy": "default",
      "default": "info"
    },
    {
      "key": "PGDOG_PORT",
      "service": "pgdog",
      "description": "TCP port PgDog listens on for PostgreSQL connections",
      "secret": false,
      "strategy": "default",
      "default": "6432"
    },
    {
      "key": "PGDOG_USER",
      "service": "pgdog",
      "description": "Username applications use when connecting to PgDog",
      "secret": false,
      "strategy": "default",
      "default": "pgdog"
    },
    {
      "key": "SHARD_0_HOST",
      "service": "pgdog",
      "description": "Private hostname for PostgreSQL shard 0",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "SHARD_0_PORT",
      "service": "pgdog",
      "description": "PostgreSQL port for shard 0",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SHARD_0_USER",
      "service": "pgdog",
      "description": "PostgreSQL user for shard 0",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SHARD_1_HOST",
      "service": "pgdog",
      "description": "Private hostname for PostgreSQL shard 1",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "SHARD_1_PORT",
      "service": "pgdog",
      "description": "PostgreSQL port for shard 1",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SHARD_1_USER",
      "service": "pgdog",
      "description": "PostgreSQL user for shard 1",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDOG_DATABASE",
      "service": "pgdog",
      "description": "Virtual database name exposed by PgDog",
      "secret": false,
      "strategy": "default",
      "default": "app"
    },
    {
      "key": "PGDOG_PASSWORD",
      "service": "pgdog",
      "description": "Password applications use when connecting to PgDog",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "PGDOG_POOL_SIZE",
      "service": "pgdog",
      "description": "Maximum backend PostgreSQL connections per pool",
      "secret": false,
      "strategy": "default",
      "default": "10"
    },
    {
      "key": "SHARDING_COLUMN",
      "service": "pgdog",
      "description": "Column PgDog uses as the sharding key",
      "secret": false,
      "strategy": "default",
      "default": "tenant_id"
    },
    {
      "key": "SHARD_0_DATABASE",
      "service": "pgdog",
      "description": "Database name for shard 0",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SHARD_0_PASSWORD",
      "service": "pgdog",
      "description": "PostgreSQL password for shard 0",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SHARD_1_DATABASE",
      "service": "pgdog",
      "description": "Database name for shard 1",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SHARD_1_PASSWORD",
      "service": "pgdog",
      "description": "PostgreSQL password for shard 1",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SHARDING_DATA_TYPE",
      "service": "pgdog",
      "description": "Data type of the sharding key: bigint, uuid, varchar, or vector",
      "secret": false,
      "strategy": "default",
      "default": "bigint"
    },
    {
      "key": "PGDATA",
      "service": "Postgres-Shard-0",
      "description": "Location where the database will be initialized",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "Postgres-Shard-0",
      "description": "Railway Private Domain Name.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "Postgres-Shard-0",
      "description": "Port to connect to Postgres.",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "Postgres-Shard-0",
      "description": "Required variable for Data panel",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "Postgres-Shard-0",
      "description": "Required variable for the data panel.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "Postgres-Shard-0",
      "description": "Required variable for Data panel",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres-Shard-0",
      "description": "Default database created when image is started.",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "Postgres-Shard-0",
      "description": "URL to connect to Postgres database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres-Shard-0",
      "description": "User to connect to Postgres DB",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "Postgres-Shard-0",
      "description": "SSL certificate expiry in days.",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres-Shard-0",
      "description": "Password to connect to DB",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres-Shard-0",
      "description": "Allow Postgres to cleanly shut down",
      "secret": false,
      "strategy": "default",
      "default": "60"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "pgdog-with-postgres"
      }
    },
    "cli": "railway deploy --template pgdog-with-postgres",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "67c29a1a-e869-448e-bc42-252d66f82be5",
            "serializedConfig": {
              "services": {
                "9e7b295d-9425-46c4-8564-ee5bca1e172e": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres-Shard-1",
                  "deploy": {
                    "requiredMountPath": "/var/lib/postgresql/data"
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Location where the database will be initialized",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": false,
                      "description": "Railway Private Domain Name.",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": false,
                      "description": "Port to connect to Postgres.",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": false,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{ POSTGRES_USER }}"
                    },
                    "PGDATABASE": {
                      "isOptional": false,
                      "description": "Required variable for the data panel.",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": false,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Default database created when image is started.",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "URL to connect to Postgres database.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "User to connect to Postgres DB",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": true,
                      "description": "SSL certificate expiry in days.",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Password to connect to DB",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Allow Postgres to cleanly shut down",
                      "defaultValue": "60"
                    }
                  },
                  "volumeMounts": {
                    "9e7b295d-9425-46c4-8564-ee5bca1e172e": {
                      "mountPath": "/var/lib/postgresql/data"
                    }
                  },
                  "haTemplateCode": "postgres-ha",
                  "haConversionConfig": {
                    "edge": {
                      "label": "Reverse Proxy",
                      "options": [
                        2,
                        3,
                        4,
                        5
                      ],
                      "nodeLabel": "HAProxy",
                      "description": "Routes traffic to the primary",
                      "defaultValue": 3
                    },
                    "replica": {
                      "label": "Replicas",
                      "options": [
                        2,
                        3,
                        4,
                        5,
                        6,
                        7
                      ],
                      "nodeLabel": "Postgres",
                      "description": "Streaming replicas for automatic failover",
                      "defaultValue": 2
                    },
                    "internal": {
                      "label": "Coordinator Nodes",
                      "options": [
                        3,
                        5,
                        7,
                        9
                      ],
                      "nodeLabel": "etcd",
                      "defaultValue": 3
                    },
                    "description": "This will convert your Postgres database to an HA cluster with Patroni failover and etcd consensus."
                  }
                },
                "dc363564-961c-4b47-979a-89cbe33a24ee": {
                  "icon": "https://pgdog.dev/assets/images/logo2.png",
                  "name": "pgdog",
                  "deploy": {
                    "startCommand": "/bin/sh -c 'printf \"%s\\n\" \"[general]\" \"host = \\\"0.0.0.0\\\"\" \"port = ${PGDOG_PORT}\" \"default_pool_size = ${PGDOG_POOL_SIZE}\" \"\" \"[[databases]]\" \"name = \\\"${PGDOG_DATABASE}\\\"\" \"host = \\\"${SHARD_0_HOST}\\\"\" \"port = ${SHARD_0_PORT}\" \"database_name = \\\"${SHARD_0_DATABASE}\\\"\" \"user = \\\"${SHARD_0_USER}\\\"\" \"password = \\\"${SHARD_0_PASSWORD}\\\"\" \"shard = 0\" \"\" \"[[databases]]\" \"name = \\\"${PGDOG_DATABASE}\\\"\" \"host = \\\"${SHARD_1_HOST}\\\"\" \"port = ${SHARD_1_PORT}\" \"database_name = \\\"${SHARD_1_DATABASE}\\\"\" \"user = \\\"${SHARD_1_USER}\\\"\" \"password = \\\"${SHARD_1_PASSWORD}\\\"\" \"shard = 1\" \"\" \"[[sharded_tables]]\" \"database = \\\"${PGDOG_DATABASE}\\\"\" \"column = \\\"${SHARDING_COLUMN}\\\"\" \"data_type = \\\"${SHARDING_DATA_TYPE}\\\"\" > /pgdog/pgdog.toml && printf \"%s\\n\" \"[[users]]\" \"name = \\\"${PGDOG_USER}\\\"\" \"database = \\\"${PGDOG_DATABASE}\\\"\" \"password = \\\"${PGDOG_PASSWORD}\\\"\" > /pgdog/users.toml && exec /usr/local/bin/pgdog --config /pgdog/pgdog.toml --users /pgdog/users.toml'"
                  },
                  "source": {
                    "image": "ghcr.io/pgdogdev/pgdog:v0.1.48"
                  },
                  "variables": {
                    "RUST_LOG": {
                      "description": "PgDog logging level",
                      "defaultValue": "info"
                    },
                    "PGDOG_PORT": {
                      "description": "TCP port PgDog listens on for PostgreSQL connections",
                      "defaultValue": "6432"
                    },
                    "PGDOG_USER": {
                      "description": "Username applications use when connecting to PgDog",
                      "defaultValue": "pgdog"
                    },
                    "SHARD_0_HOST": {
                      "description": "Private hostname for PostgreSQL shard 0",
                      "defaultValue": "${{Postgres-Shard-0.RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "SHARD_0_PORT": {
                      "description": "PostgreSQL port for shard 0",
                      "defaultValue": "${{Postgres-Shard-0.PGPORT}}"
                    },
                    "SHARD_0_USER": {
                      "description": "PostgreSQL user for shard 0",
                      "defaultValue": "${{Postgres-Shard-0.PGUSER}}"
                    },
                    "SHARD_1_HOST": {
                      "description": "Private hostname for PostgreSQL shard 1",
                      "defaultValue": "${{Postgres-Shard-1.RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "SHARD_1_PORT": {
                      "description": "PostgreSQL port for shard 1",
                      "defaultValue": "${{Postgres-Shard-1.PGPORT}}"
                    },
                    "SHARD_1_USER": {
                      "description": "PostgreSQL user for shard 1",
                      "defaultValue": "${{Postgres-Shard-1.PGUSER}}"
                    },
                    "PGDOG_DATABASE": {
                      "description": "Virtual database name exposed by PgDog",
                      "defaultValue": "app"
                    },
                    "PGDOG_PASSWORD": {
                      "description": "Password applications use when connecting to PgDog",
                      "defaultValue": "{{PGDOG_PASSWORD}}"
                    },
                    "PGDOG_POOL_SIZE": {
                      "description": "Maximum backend PostgreSQL connections per pool",
                      "defaultValue": "10"
                    },
                    "SHARDING_COLUMN": {
                      "description": "Column PgDog uses as the sharding key",
                      "defaultValue": "tenant_id"
                    },
                    "SHARD_0_DATABASE": {
                      "description": "Database name for shard 0",
                      "defaultValue": "${{Postgres-Shard-0.PGDATABASE}}"
                    },
                    "SHARD_0_PASSWORD": {
                      "description": "PostgreSQL password for shard 0",
                      "defaultValue": "${{Postgres-Shard-0.PGPASSWORD}}"
                    },
                    "SHARD_1_DATABASE": {
                      "description": "Database name for shard 1",
                      "defaultValue": "${{Postgres-Shard-1.PGDATABASE}}"
                    },
                    "SHARD_1_PASSWORD": {
                      "description": "PostgreSQL password for shard 1",
                      "defaultValue": "${{Postgres-Shard-1.PGPASSWORD}}"
                    },
                    "SHARDING_DATA_TYPE": {
                      "description": "Data type of the sharding key: bigint, uuid, varchar, or vector",
                      "defaultValue": "bigint"
                    }
                  },
                  "networking": {
                    "tcpProxies": {
                      "6432": {}
                    }
                  }
                },
                "e1170d81-4523-40b8-a5b0-9f6086606f17": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres-Shard-0",
                  "deploy": {
                    "requiredMountPath": "/var/lib/postgresql/data"
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Location where the database will be initialized",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": false,
                      "description": "Railway Private Domain Name.",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": false,
                      "description": "Port to connect to Postgres.",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": false,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{ POSTGRES_USER }}"
                    },
                    "PGDATABASE": {
                      "isOptional": false,
                      "description": "Required variable for the data panel.",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": false,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Default database created when image is started.",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "URL to connect to Postgres database.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "User to connect to Postgres DB",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": true,
                      "description": "SSL certificate expiry in days.",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Password to connect to DB",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Allow Postgres to cleanly shut down",
                      "defaultValue": "60"
                    }
                  },
                  "volumeMounts": {
                    "e1170d81-4523-40b8-a5b0-9f6086606f17": {
                      "mountPath": "/var/lib/postgresql/data"
                    }
                  },
                  "haTemplateCode": "postgres-ha",
                  "haConversionConfig": {
                    "edge": {
                      "label": "Reverse Proxy",
                      "options": [
                        2,
                        3,
                        4,
                        5
                      ],
                      "nodeLabel": "HAProxy",
                      "description": "Routes traffic to the primary",
                      "defaultValue": 3
                    },
                    "replica": {
                      "label": "Replicas",
                      "options": [
                        2,
                        3,
                        4,
                        5,
                        6,
                        7
                      ],
                      "nodeLabel": "Postgres",
                      "description": "Streaming replicas for automatic failover",
                      "defaultValue": 2
                    },
                    "internal": {
                      "label": "Coordinator Nodes",
                      "options": [
                        3,
                        5,
                        7,
                        9
                      ],
                      "nodeLabel": "etcd",
                      "defaultValue": 3
                    },
                    "description": "This will convert your Postgres database to an HA cluster with Patroni failover and etcd consensus."
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {},
  "resources": {
    "expected_services": 3,
    "needs_volume": true
  },
  "generated_at": "2026-09-22T16:14:56.866Z",
  "generator_version": "0.1.0",
  "status": "validated",
  "validated_at": "2026-09-21T20:03:29.794Z",
  "success_rate_30d": 1,
  "validation": {
    "last_run_id": "run_e26decec4ddf4a3aa7e6",
    "checks": [
      {
        "name": "workflow_completed",
        "passed": true
      },
      {
        "name": "all_services_deployed",
        "passed": true
      },
      {
        "name": "stays_up",
        "passed": true
      }
    ],
    "typical_ready_seconds": 89,
    "typical_build_seconds": 0,
    "typical_start_seconds": 10,
    "slowest_service": "pgdog"
  }
}
