{
  "manifest_version": "1.0.0",
  "template": {
    "id": "d2bb0625-8b37-45bf-93f6-5a50d1ef25c1",
    "slug": "codex-pooler",
    "name": "Codex Pooler",
    "description": "Self-hosted Codex gateway with pooled accounts and OpenAI-compatible APIs.",
    "url": "https://railway.com/deploy/codex-pooler",
    "upstream": {
      "image": "ghcr.io/icoretech/codex-pooler:latest"
    }
  },
  "services": [
    {
      "name": "Postgres",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": false
    },
    {
      "name": "codex-pooler",
      "source": {
        "image": "ghcr.io/icoretech/codex-pooler:latest"
      },
      "needs_volume": false,
      "http": true
    }
  ],
  "required_inputs": [
    {
      "key": "PGDATA",
      "service": "Postgres",
      "description": "Directory where PostgreSQL stores persistent database files.",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "Postgres",
      "description": "Private Railway hostname for the PostgreSQL service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "Postgres",
      "description": "Internal PostgreSQL server port.",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "Postgres",
      "description": "PostgreSQL username exposed to connected services.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "Postgres",
      "description": "Default PostgreSQL database exposed to connected services.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "Postgres",
      "description": "Reference to the generated PostgreSQL password.",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres",
      "description": "Database created when PostgreSQL initializes.",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "Postgres",
      "description": "Private PostgreSQL connection URL for application services.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres",
      "description": "Administrator role created when PostgreSQL initializes.",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "Postgres",
      "description": "Validity period in days for the generated PostgreSQL TLS certificate.",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres",
      "description": "Generated password for the PostgreSQL administrator role.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "DATABASE_PUBLIC_URL",
      "service": "Postgres",
      "description": "Public TCP proxy connection URL for external database clients.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres",
      "description": "Seconds allowed for graceful PostgreSQL shutdown during deployment.",
      "secret": false,
      "strategy": "default",
      "default": "60"
    },
    {
      "key": "PORT",
      "service": "codex-pooler",
      "description": "HTTP port used by the Phoenix web server.",
      "secret": false,
      "strategy": "default",
      "default": "4000"
    },
    {
      "key": "PHX_HOST",
      "service": "codex-pooler",
      "description": "Public hostname used to generate HTTPS URLs.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "ECTO_IPV6",
      "service": "codex-pooler",
      "description": "Enables IPv6 sockets for PostgreSQL connections when set to true.",
      "secret": false,
      "strategy": "default",
      "default": "false"
    },
    {
      "key": "OBAN_MODE",
      "service": "codex-pooler",
      "description": "Runs web, scheduler, and background jobs together in this service.",
      "secret": false,
      "strategy": "default",
      "default": "all"
    },
    {
      "key": "POOL_SIZE",
      "service": "codex-pooler",
      "description": "Maximum PostgreSQL connections in the application pool.",
      "secret": false,
      "strategy": "default",
      "default": "10"
    },
    {
      "key": "PHX_SERVER",
      "service": "codex-pooler",
      "description": "Starts the Phoenix HTTP endpoint in the release.",
      "secret": false,
      "strategy": "default",
      "default": "true"
    },
    {
      "key": "DATABASE_URL",
      "service": "codex-pooler",
      "description": "Private PostgreSQL connection URL supplied by the Postgres service.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "SECRET_KEY_BASE",
      "service": "codex-pooler",
      "description": "Generated secret used to sign and encrypt Phoenix data.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "OBAN_JOBS_QUEUE_LIMIT",
      "service": "codex-pooler",
      "description": "Maximum number of concurrent Oban jobs.",
      "secret": false,
      "strategy": "default",
      "default": "8"
    },
    {
      "key": "CODEX_POOLER_TOTP_KEY_VERSION",
      "service": "codex-pooler",
      "description": "Version label for the TOTP encryption key.",
      "secret": true,
      "strategy": "default",
      "default": "v1"
    },
    {
      "key": "RAILWAY_HEALTHCHECK_TIMEOUT_SEC",
      "service": "codex-pooler",
      "description": "Seconds Railway waits for the service health check.",
      "secret": false,
      "strategy": "default",
      "default": "300"
    },
    {
      "key": "CODEX_POOLER_TOTP_ENCRYPTION_KEY",
      "service": "codex-pooler",
      "description": "Generated 32-byte key used to encrypt operator TOTP secrets.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "CODEX_POOLER_UPSTREAM_SECRET_KEY",
      "service": "codex-pooler",
      "description": "Generated 32-byte key used to encrypt upstream credentials.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "CODEX_POOLER_OPERATOR_LOGIN_BASE_URL",
      "service": "codex-pooler",
      "description": "Public base URL used for operator login links and redirects.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "CODEX_POOLER_UPSTREAM_SECRET_KEY_VERSION",
      "service": "codex-pooler",
      "description": "Version label for the upstream credential encryption key.",
      "secret": true,
      "strategy": "default",
      "default": "v1"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "codex-pooler"
      }
    },
    "cli": "railway deploy --template codex-pooler",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "d2bb0625-8b37-45bf-93f6-5a50d1ef25c1",
            "serializedConfig": {
              "buckets": {},
              "services": {
                "521f667d-95d7-4b41-afe7-3708b7999a23": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres",
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Directory where PostgreSQL stores persistent database files.",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": false,
                      "description": "Private Railway hostname for the PostgreSQL service.",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": false,
                      "description": "Internal PostgreSQL server port.",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": false,
                      "description": "PostgreSQL username exposed to connected services.",
                      "defaultValue": "${{POSTGRES_USER}}"
                    },
                    "PGDATABASE": {
                      "isOptional": false,
                      "description": "Default PostgreSQL database exposed to connected services.",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": false,
                      "description": "Reference to the generated PostgreSQL password.",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Database created when PostgreSQL initializes.",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "Private PostgreSQL connection URL for application services.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "Administrator role created when PostgreSQL initializes.",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": false,
                      "description": "Validity period in days for the generated PostgreSQL TLS certificate.",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Generated password for the PostgreSQL administrator role.",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "DATABASE_PUBLIC_URL": {
                      "isOptional": false,
                      "description": "Public TCP proxy connection URL for external database clients.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_TCP_PROXY_DOMAIN}}:${{RAILWAY_TCP_PROXY_PORT}}/${{PGDATABASE}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Seconds allowed for graceful PostgreSQL shutdown during deployment.",
                      "defaultValue": "60"
                    }
                  },
                  "volumeMounts": {
                    "521f667d-95d7-4b41-afe7-3708b7999a23": {
                      "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."
                  }
                },
                "78639b2b-e0ee-4871-a196-48cb4df85014": {
                  "icon": "https://raw.githubusercontent.com/icoretech/codex-pooler/main/.github/assets/pooler.png",
                  "name": "codex-pooler",
                  "deploy": {
                    "startCommand": "/bin/sh -lc 'set -e; env -u PHX_SERVER /app/bin/codex_pooler eval \"CodexPooler.Release.migrate()\"; env -u PHX_SERVER /app/bin/codex_pooler eval \"CodexPooler.Release.import_openai_pricing_from_priv()\"; exec /app/bin/codex_pooler start'",
                    "healthcheckPath": "/metrics",
                    "preDeployCommand": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "ghcr.io/icoretech/codex-pooler:latest"
                  },
                  "variables": {
                    "PORT": {
                      "isOptional": false,
                      "description": "HTTP port used by the Phoenix web server.",
                      "defaultValue": "4000"
                    },
                    "PHX_HOST": {
                      "isOptional": false,
                      "description": "Public hostname used to generate HTTPS URLs.",
                      "defaultValue": "${{RAILWAY_PUBLIC_DOMAIN}}"
                    },
                    "ECTO_IPV6": {
                      "isOptional": false,
                      "description": "Enables IPv6 sockets for PostgreSQL connections when set to true.",
                      "defaultValue": "false"
                    },
                    "OBAN_MODE": {
                      "isOptional": false,
                      "description": "Runs web, scheduler, and background jobs together in this service.",
                      "defaultValue": "all"
                    },
                    "POOL_SIZE": {
                      "isOptional": false,
                      "description": "Maximum PostgreSQL connections in the application pool.",
                      "defaultValue": "10"
                    },
                    "PHX_SERVER": {
                      "isOptional": false,
                      "description": "Starts the Phoenix HTTP endpoint in the release.",
                      "defaultValue": "true"
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "Private PostgreSQL connection URL supplied by the Postgres service.",
                      "defaultValue": "${{Postgres.DATABASE_URL}}"
                    },
                    "SECRET_KEY_BASE": {
                      "isOptional": false,
                      "description": "Generated secret used to sign and encrypt Phoenix data.",
                      "defaultValue": "{{SECRET_KEY_BASE}}"
                    },
                    "OBAN_JOBS_QUEUE_LIMIT": {
                      "isOptional": false,
                      "description": "Maximum number of concurrent Oban jobs.",
                      "defaultValue": "8"
                    },
                    "CODEX_POOLER_TOTP_KEY_VERSION": {
                      "isOptional": false,
                      "description": "Version label for the TOTP encryption key.",
                      "defaultValue": "v1"
                    },
                    "RAILWAY_HEALTHCHECK_TIMEOUT_SEC": {
                      "isOptional": false,
                      "description": "Seconds Railway waits for the service health check.",
                      "defaultValue": "300"
                    },
                    "CODEX_POOLER_TOTP_ENCRYPTION_KEY": {
                      "isOptional": false,
                      "description": "Generated 32-byte key used to encrypt operator TOTP secrets.",
                      "defaultValue": "{{CODEX_POOLER_TOTP_ENCRYPTION_KEY}}"
                    },
                    "CODEX_POOLER_UPSTREAM_SECRET_KEY": {
                      "isOptional": false,
                      "description": "Generated 32-byte key used to encrypt upstream credentials.",
                      "defaultValue": "{{CODEX_POOLER_UPSTREAM_SECRET_KEY}}"
                    },
                    "CODEX_POOLER_OPERATOR_LOGIN_BASE_URL": {
                      "isOptional": false,
                      "description": "Public base URL used for operator login links and redirects.",
                      "defaultValue": "https://${{RAILWAY_PUBLIC_DOMAIN}}"
                    },
                    "CODEX_POOLER_UPSTREAM_SECRET_KEY_VERSION": {
                      "isOptional": false,
                      "description": "Version label for the upstream credential encryption key.",
                      "defaultValue": "v1"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>": {}
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {
    "healthcheck": {
      "service": "codex-pooler",
      "method": "GET",
      "path": "/metrics",
      "expect_status": 200
    }
  },
  "resources": {
    "expected_services": 2,
    "needs_volume": true
  },
  "generated_at": "2026-09-10T16:14:52.212Z",
  "generator_version": "0.1.0",
  "status": "validated",
  "validated_at": "2026-09-09T00:59:46.957Z",
  "success_rate_30d": 1,
  "validation": {
    "last_run_id": "run_91487b867cc849a98572",
    "checks": [
      {
        "name": "workflow_completed",
        "passed": true
      },
      {
        "name": "all_services_deployed",
        "passed": true
      },
      {
        "name": "healthcheck",
        "passed": true
      },
      {
        "name": "stays_up",
        "passed": true
      }
    ],
    "typical_ready_seconds": 82,
    "typical_build_seconds": 0,
    "typical_start_seconds": 20,
    "slowest_service": "codex-pooler"
  }
}
