Skip to content

Commit

Permalink
self-hosting docs improvements (#34116)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 78d557fc5eb74a5ad88f39d84b980ae358350dcd
  • Loading branch information
emmaling27 authored and Convex, Inc. committed Feb 6, 2025
1 parent f284b95 commit 7e475ee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
49 changes: 41 additions & 8 deletions self-hosted/SELFHOSTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,58 @@ npx convex import <import args>

# Self Hosting with [Fly.io](https://fly.io/)

From the self-hosted directory, deploy the backend.

```sh
# From the self-hosted directory, deploy the backend.
fly launch
# Copy and paste the url that is output to set NEXT_PUBLIC_DEPLOYMENT_URL in the dashboard/fly.toml file.
```

Copy and paste the url that is output to set `NEXT_PUBLIC_DEPLOYMENT_URL` in the
dashboard/fly.toml file.

```sh
cd dashboard
fly launch
# Visit the dashboard at the url output from the fly deploy command.
# Generate admin key to login to the dashboard.
```

Visit the dashboard at the url output from the fly deploy command. Generate
admin key to login to the dashboard.

```sh
fly ssh console --app self-hosted-backend --command "./generate_admin_key.sh"
```

# In your frontend app directory
In your frontend app directory

```sh
npm install convex@alpha
# Write these environment variables to .env.local
```

Write these environment variables to .env.local

```sh
CONVEX_SELF_HOST_URL='<NEXT_PUBLIC_DEPLOYMENT_URL>'
CONVEX_SELF_HOST_ADMIN_KEY='<your-admin-key>'
# Push your Convex functions
```

Push your Convex functions

```sh
npx convex self-host deploy
# Visit the dashboard - you should see your functions and be able to edit data, run functions, etc.
```

Visit the dashboard - you should see your functions and be able to edit data,
run functions, etc.

### HTTP Actions

Note that HTTP actions run on your fly app url under the `/http` path. For
example:

- If your fly app is deployed at `https://self-hosted-backend.fly.dev`
- And you have an HTTP action named `sendEmail`
- You would call it at `https://self-hosted-backend.fly.dev/http/sendEmail`

## Connecting to [Neon Postgres](https://neon.tech)

Create a project on Neon. Copy the connection string from the Neon dashboard.
Expand All @@ -108,6 +139,8 @@ fly secrets set DATABASE_URL=$DATABASE_URL
fly logs
```

These instructions should work for any Postgres database, not just Neon.

# Self Hosting Via Running Binary Directly

### Get convex-local-backend Binary
Expand Down
2 changes: 1 addition & 1 deletion self-hosted/dashboard/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ primary_region = 'sjc'
image = 'ghcr.io/get-convex/self-hosted-dashboard:latest'

[env]
NEXT_PUBLIC_DEPLOYMENT_URL = 'https://self-hosted-backend.fly.dev'
NEXT_PUBLIC_DEPLOYMENT_URL =

[[services]]
internal_port = 6791
Expand Down

0 comments on commit 7e475ee

Please sign in to comment.