{
  "manifest_version": "1.0.0",
  "template": {
    "id": "b1e63d53-ce81-425a-8e4f-990e7d45f63e",
    "slug": "affine-production",
    "name": "AFFiNE | Open-Source Notion & Miro Alternative with Postgres",
    "description": "Docs, whiteboards and databases in one workspace, self-hosted",
    "url": "https://railway.com/deploy/affine-production",
    "upstream": {
      "image": "ghcr.io/toeverything/affine:0.27.4"
    }
  },
  "services": [
    {
      "name": "Postgres",
      "source": {
        "image": "pgvector/pgvector:0.8.7-pg17"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": false
    },
    {
      "name": "Redis",
      "source": {
        "image": "redis:8.10.2-alpine"
      },
      "needs_volume": true,
      "volume_mount_path": "/data",
      "http": false
    },
    {
      "name": "AFFiNE",
      "source": {
        "image": "ghcr.io/toeverything/affine:0.27.4"
      },
      "needs_volume": true,
      "volume_mount_path": "/root/.affine",
      "http": true
    }
  ],
  "required_inputs": [
    {
      "key": "PGDATA",
      "service": "Postgres",
      "description": "Data subdirectory - keeps Postgres happy on Railway volumes",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres",
      "description": "Database name",
      "secret": false,
      "strategy": "default",
      "default": "affine"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres",
      "description": "Database user",
      "secret": false,
      "strategy": "default",
      "default": "affine"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres",
      "description": "Auto-generated database password",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres",
      "description": "Time for Postgres to shut down cleanly on redeploy",
      "secret": false,
      "strategy": "default",
      "default": "60"
    },
    {
      "key": "REDIS_PASSWORD",
      "service": "Redis",
      "description": "Auto-generated Redis password",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "PORT",
      "service": "AFFiNE",
      "description": "Port Railway routes to - leave as is",
      "secret": false,
      "strategy": "default",
      "default": "3010"
    },
    {
      "key": "LISTEN_ADDR",
      "service": "AFFiNE",
      "description": "Listen on IPv6 and IPv4 so Railway's private network can reach it",
      "secret": false,
      "strategy": "default",
      "default": "::"
    },
    {
      "key": "MAILER_PORT",
      "service": "AFFiNE",
      "description": "SMTP port",
      "secret": false,
      "strategy": "default",
      "default": "465"
    },
    {
      "key": "DATABASE_URL",
      "service": "AFFiNE",
      "description": "Postgres (with pgvector) on the private network",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "REDIS_SERVER_HOST",
      "service": "AFFiNE",
      "description": "Redis on the private network",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "REDIS_SERVER_PORT",
      "service": "AFFiNE",
      "description": "Redis port",
      "secret": false,
      "strategy": "default",
      "default": "6379"
    },
    {
      "key": "AFFINE_SERVER_PORT",
      "service": "AFFiNE",
      "description": "Port AFFiNE listens on - must match PORT",
      "secret": false,
      "strategy": "default",
      "default": "3010"
    },
    {
      "key": "REDIS_SERVER_PASSWORD",
      "service": "AFFiNE",
      "description": "Redis password",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "AFFINE_INDEXER_ENABLED",
      "service": "AFFiNE",
      "description": "Full-text indexer needs a separate Manticore/Elasticsearch service; off like upstream's self-host compose",
      "secret": false,
      "strategy": "default",
      "default": "false"
    },
    {
      "key": "AFFINE_SERVER_EXTERNAL_URL",
      "service": "AFFiNE",
      "description": "Public URL of AFFiNE (invite links, OAuth callbacks, desktop app sign-in) - set it to your custom domain after adding one",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_domain"
    },
    {
      "key": "RAILWAY_HEALTHCHECK_TIMEOUT_SEC",
      "service": "AFFiNE",
      "description": "Every boot runs the database migrations before the health check can pass",
      "secret": false,
      "strategy": "default",
      "default": "600"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "affine-production"
      }
    },
    "cli": "railway deploy --template affine-production",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "b1e63d53-ce81-425a-8e4f-990e7d45f63e",
            "serializedConfig": {
              "services": {
                "b3a58463-a4ae-46e8-a85d-7ca670c9d97f": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres",
                  "build": {},
                  "deploy": {
                    "startCommand": null,
                    "healthcheckPath": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "pgvector/pgvector:0.8.7-pg17"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": false,
                      "description": "Data subdirectory - keeps Postgres happy on Railway volumes",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "POSTGRES_DB": {
                      "isOptional": false,
                      "description": "Database name",
                      "defaultValue": "affine"
                    },
                    "POSTGRES_USER": {
                      "isOptional": false,
                      "description": "Database user",
                      "defaultValue": "affine"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": false,
                      "description": "Auto-generated database password",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": false,
                      "description": "Time for Postgres to shut down cleanly on redeploy",
                      "defaultValue": "60"
                    }
                  },
                  "networking": {
                    "serviceDomains": {}
                  },
                  "volumeMounts": {
                    "a0673481-7994-4bbb-a884-f4c98fac77c1": {
                      "mountPath": "/var/lib/postgresql/data"
                    }
                  }
                },
                "b8a55529-7822-47c5-a3b2-8e1841c1cce4": {
                  "icon": "https://devicons.railway.app/i/redis.svg",
                  "name": "Redis",
                  "build": {},
                  "deploy": {
                    "startCommand": "/bin/sh -c \"chown -R redis:redis /data && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --appendonly yes\"",
                    "healthcheckPath": null,
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "redis:8.10.2-alpine"
                  },
                  "variables": {
                    "REDIS_PASSWORD": {
                      "isOptional": false,
                      "description": "Auto-generated Redis password",
                      "defaultValue": "{{REDIS_PASSWORD}}"
                    }
                  },
                  "networking": {
                    "serviceDomains": {}
                  },
                  "volumeMounts": {
                    "0c49c000-2dbd-411d-b96b-dca2b3e9e3c7": {
                      "mountPath": "/data"
                    }
                  }
                },
                "c56a509e-ed32-4e96-93c1-2973e4939d19": {
                  "icon": "https://raw.githubusercontent.com/nomideusz/affine-railway/main/icon.svg",
                  "name": "AFFiNE",
                  "build": {},
                  "deploy": {
                    "startCommand": "/bin/sh -c \"node ./scripts/self-host-predeploy.js && exec node ./dist/main.js\"",
                    "healthcheckPath": "/info",
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "ghcr.io/toeverything/affine:0.27.4"
                  },
                  "variables": {
                    "PORT": {
                      "isOptional": false,
                      "description": "Port Railway routes to - leave as is",
                      "defaultValue": "3010"
                    },
                    "LISTEN_ADDR": {
                      "isOptional": false,
                      "description": "Listen on IPv6 and IPv4 so Railway's private network can reach it",
                      "defaultValue": "::"
                    },
                    "MAILER_HOST": {
                      "isOptional": true,
                      "description": "Optional SMTP server for invitations, sign-in links and password resets (Railway allows outbound SMTP on Pro only)",
                      "defaultValue": ""
                    },
                    "MAILER_PORT": {
                      "isOptional": true,
                      "description": "SMTP port",
                      "defaultValue": "465"
                    },
                    "MAILER_USER": {
                      "isOptional": true,
                      "description": "SMTP username",
                      "defaultValue": ""
                    },
                    "DATABASE_URL": {
                      "isOptional": false,
                      "description": "Postgres (with pgvector) on the private network",
                      "defaultValue": "postgresql://${{Postgres.POSTGRES_USER}}:${{Postgres.POSTGRES_PASSWORD}}@${{Postgres.RAILWAY_PRIVATE_DOMAIN}}:5432/${{Postgres.POSTGRES_DB}}"
                    },
                    "MAILER_SENDER": {
                      "isOptional": true,
                      "description": "Sender, e.g. AFFiNE <noreply@example.com>",
                      "defaultValue": ""
                    },
                    "MAILER_PASSWORD": {
                      "isOptional": true,
                      "description": "SMTP password",
                      "defaultValue": ""
                    },
                    "REDIS_SERVER_HOST": {
                      "isOptional": false,
                      "description": "Redis on the private network",
                      "defaultValue": "${{Redis.RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "REDIS_SERVER_PORT": {
                      "isOptional": false,
                      "description": "Redis port",
                      "defaultValue": "6379"
                    },
                    "AFFINE_SERVER_PORT": {
                      "isOptional": false,
                      "description": "Port AFFiNE listens on - must match PORT",
                      "defaultValue": "3010"
                    },
                    "REDIS_SERVER_PASSWORD": {
                      "isOptional": false,
                      "description": "Redis password",
                      "defaultValue": "${{Redis.REDIS_PASSWORD}}"
                    },
                    "AFFINE_INDEXER_ENABLED": {
                      "isOptional": false,
                      "description": "Full-text indexer needs a separate Manticore/Elasticsearch service; off like upstream's self-host compose",
                      "defaultValue": "false"
                    },
                    "AFFINE_SERVER_EXTERNAL_URL": {
                      "isOptional": false,
                      "description": "Public URL of AFFiNE (invite links, OAuth callbacks, desktop app sign-in) - set it to your custom domain after adding one",
                      "defaultValue": "https://${{RAILWAY_PUBLIC_DOMAIN}}"
                    },
                    "RAILWAY_HEALTHCHECK_TIMEOUT_SEC": {
                      "isOptional": false,
                      "description": "Every boot runs the database migrations before the health check can pass",
                      "defaultValue": "600"
                    }
                  },
                  "networking": {
                    "serviceDomains": {
                      "<hasDomain>": {}
                    }
                  },
                  "volumeMounts": {
                    "e5bb040f-4818-41c9-a81f-f77cc650dbd6": {
                      "mountPath": "/root/.affine"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {
    "healthcheck": {
      "service": "AFFiNE",
      "method": "GET",
      "path": "/info",
      "expect_status": 200
    }
  },
  "resources": {
    "expected_services": 3,
    "needs_volume": true
  },
  "generated_at": "2026-10-06T04:14:42.626Z",
  "generator_version": "0.1.0",
  "status": "validated",
  "validated_at": "2026-10-05T05:37:34.313Z",
  "success_rate_30d": 1,
  "validation": {
    "last_run_id": "run_21fd7d302e1b4c4dbe14",
    "checks": [
      {
        "name": "workflow_completed",
        "passed": true
      },
      {
        "name": "all_services_deployed",
        "passed": true
      },
      {
        "name": "healthcheck",
        "passed": true
      },
      {
        "name": "stays_up",
        "passed": true
      }
    ],
    "typical_ready_seconds": 38,
    "typical_build_seconds": 0,
    "typical_start_seconds": 10,
    "slowest_service": "AFFiNE"
  }
}
