|
| 1 | +# Self-hosting Convex with [Railway.com](https://railway.com/) |
| 2 | + |
| 3 | +## Deploying to Railway.com |
| 4 | + |
| 5 | +You can view the ready to deploy |
| 6 | +[template here](https://railway.com/template/OKpPqB) |
| 7 | + |
| 8 | +or use one click deploy button below: |
| 9 | + |
| 10 | +[](https://railway.com/template/OKpPqB) |
| 11 | + |
| 12 | +## Setup |
| 13 | + |
| 14 | +The template comes with pre-configured env-variables and you need to follow some |
| 15 | +setup steps to make it fully work. |
| 16 | + |
| 17 | +1. Setting up ports for the deployment |
| 18 | +2. Generating admin key with railway ssh |
| 19 | + |
| 20 | +Steps: |
| 21 | + |
| 22 | +1. Setting up ports for the deployment |
| 23 | + |
| 24 | + Go to your railway deployment |
| 25 | + |
| 26 | + - Select `convex-backend` service |
| 27 | + - Select Settings tab and scroll to `Public Networking` section |
| 28 | + - Hover on the domain and delete auto assigned domain |
| 29 | + - Click on `Generate Domain` for auto generated one or `Custom Domain` if you |
| 30 | + want to setup custom domain |
| 31 | + - Make sure to select port `3210` and add your domain |
| 32 | + - Re-deploy both `convex-dashboard` and `convex-backend` services |
| 33 | + |
| 34 | +2. Generating admin key with railway ssh |
| 35 | + |
| 36 | + Follow [these](https://blog.railway.com/p/ssh#how-to-ssh-on-railway) |
| 37 | + instructions to setup railway SSH on your machine |
| 38 | + |
| 39 | + - Link your convex deployment project |
| 40 | + - Run `railway ssh` and select `convex-backend` when prompted |
| 41 | + - Run `ls` and then `./generate_admin_key.sh` |
| 42 | + - Copy the whole admin key logged on the screen |
| 43 | + - This is your admin key keep it secret |
| 44 | + |
| 45 | +### HTTP Actions |
| 46 | + |
| 47 | +Note that HTTP actions run on your railway app url under the `/http` path. For |
| 48 | +example: |
| 49 | + |
| 50 | +- If your railway app is deployed at `https://self-hosted-backend.railway.app` |
| 51 | +- And you have an HTTP action routed to `/sendEmail` |
| 52 | +- You would call it at `https://self-hosted-backend.railway.app/http/sendEmail` |
| 53 | + |
| 54 | +### Database |
| 55 | + |
| 56 | +At this point, your data is stored in SQLite and your files are stored in the |
| 57 | +Railway volume. You can see them in the `data` folder if you run: |
| 58 | + |
| 59 | +``` |
| 60 | +railway ssh |
| 61 | +ls |
| 62 | +``` |
| 63 | + |
| 64 | +To store your data in a SQL database of your choice, see |
| 65 | +[these instructions](https://github.com/get-convex/convex-backend/tree/main/self-hosted/README.md#running-the-database-on-postgres--or-mysql). |
| 66 | + |
| 67 | +## Accessing the deployed dashboard |
| 68 | + |
| 69 | +The dashboard allows you to see logs, read/write data, run functions, and more. |
| 70 | +You can run the dashboard locally with Docker, or deploy it to Railway. |
| 71 | + |
| 72 | +- Head over to your railway app |
| 73 | +- Select `convex-dashboard` |
| 74 | +- Visit its public url |
| 75 | +- Paste the admin key when prompted |
| 76 | +- Enjoy |
| 77 | + |
| 78 | +### Running the dashboard locally |
| 79 | + |
| 80 | +```sh |
| 81 | +docker run -e 'NEXT_PUBLIC_DEPLOYMENT_URL=<backend-url>' -p '6791:6791' 'ghcr.io/get-convex/convex-dashboard:latest' |
| 82 | +``` |
| 83 | + |
| 84 | +## Deploying your frontend app |
| 85 | + |
| 86 | +See |
| 87 | +[these instructions](https://github.com/get-convex/convex-backend/tree/main/self-hosted/README.md#deploying-your-frontend-app). |
| 88 | + |
| 89 | +## Troubleshooting |
| 90 | + |
| 91 | +- **Performance issues**: The default railway configuration allocates the |
| 92 | + minimum possible resources to get up and running. If your app has high load, |
| 93 | + you may see ratelimiting from railway and poor performance. We recommend |
| 94 | + increasing your memory and CPU. |
| 95 | +- **Running out of disk space**: The hobby railway configuration allocates 5GB |
| 96 | + to the `convex_data` volume where your SQLite database and storage lives. If |
| 97 | + you run out of space, you can increase the volume to 50GB by upgrading plan. |
| 98 | +- If you need more help feel free to join our discord |
| 99 | + [community discord](https://convex.dev/community) |
0 commit comments