@@ -22,7 +22,7 @@ Development of the Convex backend is led by the Convex team. We
22
22
[ love receiving feedback] ( https://discord.gg/convex ) . We keep this repository
23
23
synced with any internal development work within a handful of days.
24
24
25
- # Self Hosting Via Docker [ recommended ]
25
+ # Self Hosting Via Docker
26
26
27
27
You'll need to have [ Docker] ( https://docs.docker.com/desktop/ ) installed to run
28
28
convex in Docker.
@@ -66,6 +66,13 @@ npx convex run <run args>
66
66
npx convex import < import args>
67
67
```
68
68
69
+ By default, the backend will store its data in a volume managed by Docker. Note
70
+ that you'll need to set up persistent storage on whatever cloud hosting platform
71
+ you choose to run the Docker container on (e.g. AWS EBS). The default database
72
+ is SQLite, but for production workloads, we recommend running Convex backed by
73
+ Postgres. Follow [ these instructions] ( #self-hosting-on-postgres-with-neon ) to
74
+ connect to Postgres.
75
+
69
76
# Self Hosting with [ Fly.io] ( https://fly.io/ )
70
77
71
78
From the self-hosted directory, deploy the backend.
@@ -120,22 +127,40 @@ example:
120
127
- And you have an HTTP action named ` sendEmail `
121
128
- You would call it at ` https://self-hosted-backend.fly.dev/http/sendEmail `
122
129
123
- ## Connecting to [ Neon Postgres] ( https://neon.tech )
130
+ # Self Hosting on Postgres with [ Neon ] ( https://neon.tech )
124
131
125
132
Create a project on Neon. Copy the connection string from the Neon dashboard.
126
133
127
134
``` sh
128
135
export DATABASE_CONNECTION=' <connection string>'
136
+ ```
129
137
130
- # Create the database
138
+ Create the database
139
+
140
+ ``` sh
131
141
psql $DATABASE_CONNECTION -c " CREATE DATABASE convex_self_hosted"
142
+ ```
143
+
144
+ Strip database name and query params from the connection string. It should end
145
+ in neon.tech
132
146
133
- # Strip database name and query params from the connection string. It should end in neon.tech
147
+ ``` sh
134
148
export DATABASE_URL=$( echo $DATABASE_CONNECTION | sed -E ' s/\/[^/]+(\?.*)?$//' )
149
+ ```
150
+
151
+ Update your ` DATABASE_URL ` environment variable. If you're deploying on
152
+ [ Fly] ( https://fly.io ) :
153
+
154
+ ``` sh
135
155
fly secrets set DATABASE_URL=$DATABASE_URL
156
+ ```
157
+
158
+ After you've deployed with the environment variable set, check that the database
159
+ is connected to your self-hosted convex backend. There should be a line like
160
+ "Connected to Postgres" in the logs. If you're deploying on
161
+ [ Fly] ( https://fly.io ) :
136
162
137
- # Check that the database is connected to your self-hosted convex backend.
138
- # There should be a line like "Connected to Postgres" in the logs.
163
+ ``` sh
139
164
fly logs
140
165
```
141
166
0 commit comments