Skip to content

Commit 549a858

Browse files
nipunn1313orenaksakal
authored and
Convex, Inc.
committed
convex-backend PR 57: Add selfhosted railway template and documentation (#35122)
Adds selfhosted railway template link and documentation ---- By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. Co-authored-by: Oren Aksakal <[email protected]> GitOrigin-RevId: 085165c55d357f3db89c0eb329318b293cbb9ea7
1 parent 594c77f commit 549a858

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules/
22
target/
33
convex_local_backend*.sqlite3
44
convex_local_storage/
5+
.DS_Store
56
# testing 123

Diff for: self-hosted/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ You can run the Convex backend on a hosting provider of your choice. We include
170170
[Fly.io](https://fly.io/). See our dedicated [Fly instructions](./fly/README.md)
171171
to get started.
172172

173+
## Backend hosting on Railway.com
174+
175+
You can run the Convex backend on a hosting provider of your choice. We include
176+
ready made template to make it easy to deploy your backend to
177+
[Railway.com](https://railway.com/). See our dedicated
178+
[Railway instructions](./railway/README.md) to get started.
179+
173180
## Backend hosting on your own infrastructure
174181

175182
It's possible to run Convex on your own servers, with your own routing.

Diff for: self-hosted/railway/README.md

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
[![Deploy on Railway.com](https://railway.com/button.svg)](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

Comments
 (0)