|
| 1 | +--- |
| 2 | +title: Deploy on Railway |
| 3 | +--- |
| 4 | + |
| 5 | +This guide covers deploying Permify on Railway, either via a one-click template or manual setup. |
| 6 | + |
| 7 | +## One-Click Deploy |
| 8 | + |
| 9 | +The fastest way to get started: |
| 10 | + |
| 11 | +[](https://railway.com/deploy/permify) |
| 12 | + |
| 13 | +This template automatically provisions: |
| 14 | +- A Permify instance with API authentication enabled |
| 15 | +- A PostgreSQL database for persistent storage |
| 16 | +- Private networking between services |
| 17 | + |
| 18 | +## What Gets Deployed |
| 19 | + |
| 20 | +### Permify Service |
| 21 | + |
| 22 | +The template deploys the latest Permify container image with the following default configuration: |
| 23 | + |
| 24 | +| Variable | Default Value | Description | |
| 25 | +|----------|---------------|-------------| |
| 26 | +| `PERMIFY_DATABASE_ENGINE` | `postgres` | Database backend | |
| 27 | +| `PERMIFY_DATABASE_URI` | Auto-configured | Connection string to PostgreSQL | |
| 28 | +| `PERMIFY_AUTHN_ENABLED` | `true` | Enable API authentication | |
| 29 | +| `PERMIFY_AUTHN_METHOD` | `preshared` | Authentication method | |
| 30 | +| `PERMIFY_AUTHN_PRESHARED_KEYS` | Auto-generated | 32-character secret key | |
| 31 | +| `PERMIFY_LOG_LEVEL` | `info` | Logging verbosity | |
| 32 | + |
| 33 | +### PostgreSQL Database |
| 34 | + |
| 35 | +A dedicated PostgreSQL instance is provisioned and connected to Permify over Railway's private network. The database connection is configured automatically—no manual setup required. |
| 36 | + |
| 37 | +## Connecting Your Application |
| 38 | + |
| 39 | +After deployment, add these environment variables to your application service to connect to Permify: |
| 40 | +```shell |
| 41 | +PERMIFY_HOST=${{Permify.RAILWAY_PRIVATE_DOMAIN}} |
| 42 | +PERMIFY_GRPC_PORT=3478 |
| 43 | +PERMIFY_REST_PORT=3476 |
| 44 | +PERMIFY_API_KEY=${{Permify.PERMIFY_AUTHN_PRESHARED_KEYS}} |
| 45 | +``` |
| 46 | + |
| 47 | +### Available Endpoints |
| 48 | + |
| 49 | +Permify exposes two ports: |
| 50 | + |
| 51 | +| Port | Protocol | Description | |
| 52 | +|------|----------|-------------| |
| 53 | +| 3476 | HTTP/REST | REST API and health checks | |
| 54 | +| 3478 | gRPC | High-performance gRPC API | |
| 55 | + |
| 56 | +<Note> |
| 57 | +Both ports are accessible over Railway's private network by default. To expose them publicly, configure a public domain in your Railway service settings. |
| 58 | +</Note> |
| 59 | + |
| 60 | +## Verifying the Deployment |
| 61 | + |
| 62 | +By default, Permify runs on Railway's private network with no public access. To verify the deployment: |
| 63 | + |
| 64 | +**Option 1: Check Railway logs** |
| 65 | + |
| 66 | +View the deployment logs in Railway's dashboard. A successful start shows: |
| 67 | +``` |
| 68 | +🚀 grpc server successfully started: 3478 |
| 69 | +🚀 http server successfully started: 3476 |
| 70 | +``` |
| 71 | + |
| 72 | +**Option 2: Expose a public domain** |
| 73 | + |
| 74 | +To test externally, add a public domain in Railway's service settings (Settings → Networking → Public Networking). Then: |
| 75 | +``` |
| 76 | +curl https://<your-public-domain>/healthz |
| 77 | +``` |
| 78 | + |
| 79 | +You should see: |
| 80 | +```json |
| 81 | +{"status":"SERVING"} |
| 82 | +``` |
| 83 | + |
| 84 | +**Option 3: From another Railway service** |
| 85 | + |
| 86 | +Your application can reach Permify on the private network at: |
| 87 | +``` |
| 88 | +http://permify.railway.internal:3476/healthz |
| 89 | +``` |
| 90 | + |
| 91 | +## Manual Deployment |
| 92 | + |
| 93 | +If you prefer to deploy manually instead of using the template: |
| 94 | + |
| 95 | +### 1. Create a New Project |
| 96 | + |
| 97 | +Create a new project in Railway and add a PostgreSQL database. |
| 98 | + |
| 99 | +### 2. Add the Permify Service |
| 100 | + |
| 101 | +Add a new service and deploy from the Docker image: |
| 102 | +``` |
| 103 | +ghcr.io/permify/permify:latest |
| 104 | +``` |
| 105 | + |
| 106 | +### 3. Configure Environment Variables |
| 107 | + |
| 108 | +Set the following environment variables on your Permify service: |
| 109 | +```shell |
| 110 | +PERMIFY_DATABASE_ENGINE=postgres |
| 111 | +PERMIFY_DATABASE_URI=${{Postgres.DATABASE_URL}} |
| 112 | +PERMIFY_AUTHN_ENABLED=true |
| 113 | +PERMIFY_AUTHN_METHOD=preshared |
| 114 | +PERMIFY_AUTHN_PRESHARED_KEYS=<your-secret-key> |
| 115 | +PERMIFY_LOG_LEVEL=info |
| 116 | +``` |
| 117 | + |
| 118 | +### 4. Set the Start Command |
| 119 | + |
| 120 | +Configure the start command: |
| 121 | +``` |
| 122 | +permify serve --database-auto-migrate=true |
| 123 | +``` |
| 124 | + |
| 125 | +### 5. Expose Ports |
| 126 | + |
| 127 | +In the service settings, expose ports 3476 (REST) and/or 3478 (gRPC) as needed. |
0 commit comments