Files
supabase/web/docs/guides/self-hosting.mdx
T

153 lines
5.3 KiB
Plaintext

---
id: self-hosting
title: Self Hosting
description: How to use configure and deploy Supabase.
---
Supabase is a [Hosted Platform](https://app.supabase.io), so you don't _have_ to deploy it yourself.
However, if you want to configure and deploy it yourself, that's also possible.
## Before you begin
The self-hosted version of Supabase does not include a UI yet.
We are working on this in stages, starting with our [UI library](https://github.com/supabase/ui) and with a [WIP PR here](https://github.com/supabase/supabase/pull/2281).
[[more context](https://github.com/supabase/supabase/discussions/1001#discussioncomment-558696)]
In the meantime, here are some suggestions for working with your Postgres Database:
- `pgadmin`: https://www.pgadmin.org
- `dbeaver`: https://dbeaver.com
- `BeeKeeper`: https://beekeeperstudio.io
- `HeidiSQL`: https://heidisql.com
- `Table Plus`: https://www.tableplus.io
## Get the Docker Compose
We provide a Docker Compose directory which is includes all of the tools required for building on top of Supabase.
You can download the Docker files in various ways:
### Option 1: Using our CLI
Make sure the CLI is installed:
```bash
npm install -g supabase
```
Then run in any folder to create a `docker` folder with a `docker-compose.yml`:
```bash
supabase eject
```
### Option 2: Clone our repo
```bash
# 1. Copy an empty repo
git clone https://github.com/supabase/supabase
# 2. Move into the empty repo
cd supabase/docker
```
## Running Locally
Now that you have the Docker set up on your local machine, you can start it here by running
```bash
docker-compose up
```
## Deploying
### Configuring each service
Supabase is made up of several services. We have prefilled the `docker-compose` file with all the configuration you need to get started.
If you would like to change any of the configuration, you can update the env variables in the `docker-compose` file.
Here are a list of environment variables for each service:
- [Postgres](https://hub.docker.com/_/postgres/)
- [PostgREST](https://postgrest.org/en/v7.0.0/configuration.html)
- [Realtime](https://github.com/supabase/realtime#server-set-up)
- [GoTrue](https://github.com/supabase/gotrue)
- [Storage](https://github.com/supabase/storage-api)
- [Kong](https://docs.konghq.com/install/docker/)
### Update secrets
If you are deploying to production, you should update the default [passwords and secrets](https://github.com/supabase/supabase/blob/master/docker/.env).
### Update API keys
All config for the API Gateway is stored in the `kong` directory. Inside `kong.yml` you'll find the routing for all services, the routing rules,
and down the bottom you'll find the JWTs capable of accessing services that require API Key access.
See the full docs [here](https://docs.konghq.com/hub/kong-inc/key-auth/).
If you are deploying to production, you should encode a new `anon` and `service_role` API key and update
them [here](https://github.com/supabase/supabase/blob/b1e99d2ce1f63ba728230fb53a6de444f60bce1f/docker/dockerfiles/kong/kong.yml#L42).
After you have regenerated the JWT secret in the step above, use a JWT generator (for example, using [jsonwebtoken.io](https://www.jsonwebtoken.io/)) to regenerate the API Keys using the payloads below:
```bash
# anon Payload:
{
"iss": "supabase",
"iat": 1603968834,
"exp": 2550653634,
"aud": "",
"sub": "",
"role": "anon"
}
# service_role Payload:
{
"iss": "supabase",
"iat": 1603968834,
"exp": 2550653634,
"aud": "",
"sub": "",
"role": "service_role"
}
```
### Configuring email
GoTrue requires an SMTP server to send emails for all authentication actions.
You will need to provide the following [settings](https://github.com/supabase/gotrue#e-mail) inside the `.env` file [here](https://github.com/supabase/supabase/blob/027e7f7b97bbe7365db4f7f46abe480e05841006/docker/.env#L8).
### Deploying
See the following guides to deploy Docker Compose setup using your preferred tool and platform:
- [AWS with Docker Machine](https://docs.docker.com/machine/get-started-cloud/#amazon-web-services-aws)
- [Digital Ocean with Docker Machine](https://docs.docker.com/machine/get-started-cloud/#digitalocean)
- [Docker Swarm](https://docs.docker.com/engine/swarm/stack-deploy/)
- [AWS Fargate](https://aws.amazon.com/blogs/containers/deploy-applications-on-amazon-ecs-using-docker-compose/)
- [Using Kompose for Kubernetes](https://kubernetes.io/docs/tasks/configure-pod-container/translate-compose-kubernetes/)
## One-click deploys
For some tools we also provide images and deployments into cloud marketplaces:
### Postgres
- AWS (Arm architecture) [one click deploy](https://aws.amazon.com/marketplace/pp/B08V22HK26?qid=1617156168590&sr=0-3)
- AWS [one click deploy](https://aws.amazon.com/marketplace/pp/B08915TCJ2)
- Digital Ocean [one click deploy](https://marketplace.digitalocean.com/apps/supabase-postgres)
- Docker [image](https://hub.docker.com/r/supabase/postgres)
### Realtime
- AWS [one click deploy](https://aws.amazon.com/marketplace/pp/B089N4FH7N?qid=1617156168590&sr=0-2)
- Digital Ocean [one click deploy](https://marketplace.digitalocean.com/apps/supabase-realtime)
- Docker [image](https://hub.docker.com/r/supabase/postgres)
## Next steps
- Got a question? [Ask here](https://github.com/supabase/supabase/discussions).
- Sign in: [app.supabase.io](https://app.supabase.io)