Skip to content

Commit 35503f5

Browse files
authored
Merge pull request supabase#3 from supabase/chore/self-hosting
more docs
2 parents f13251c + a49f855 commit 35503f5

File tree

8 files changed

+820
-36
lines changed

8 files changed

+820
-36
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PASSWORD_PROTECTED=true
2+
SUPABASE_PROJECT_REF=
3+
SUPABASE_SERVICE_ROLE_KEY=
4+
GRAFANA_PASSWORD=

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.vscode/
1+
.vscode/
2+
.env

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ENV GF_PATHS_DATA=/data/grafana/data \
1515
GF_AUTH_PROXY_ENABLED="true" \
1616
GF_USERS_ALLOW_SIGN_UP=false \
1717
GF_SERVER_HTTP_ADDR="0.0.0.0" \
18+
GF_SERVER_HTTP_PORT=8080 \
1819
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH="/var/lib/grafana/dashboards/dashboard.json"
1920

2021
COPY entrypoint.sh /entrypoint.sh
@@ -31,4 +32,6 @@ COPY grafana/dashboard.json /var/lib/grafana/dashboards/dashboard.json
3132

3233
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
3334

35+
EXPOSE 8080
36+
3437
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
1-
## Instructions
2-
3-
1. Make sure you have the following details available:
4-
1. Your Supabase project ref
5-
2. Your project's service role key, which can be found [here](https://app.supabase.com/project/sngruicxdhrqfujqijal/settings/api)
6-
2. Replace the following values in the `fly.toml` file:
7-
1. `my_supabase_project_ref` with your Supabase project ref
8-
2. `my_service_role_key` with your project's service role key
9-
3. If you want your Grafana instance to be password protected:
10-
1. Set `PASSWORD_PROTECTED` to `true`
11-
2. Change `GRAFANA_PASSWORD` to your desired values
12-
3. Login using `admin` and your set password
13-
3. Make sure you have the [Fly CLI](https://fly.io/docs/getting-started/installing-flyctl/) installed
14-
4. Create a Fly.io account and login using the CLI
15-
5. Run `flyctl launch` to deploy the app to Fly, ensuring that you give your app a unique name
16-
6. After a successful deployment, your app will be available at `https://<your-app-name>.fly.dev`:
1+
# `supabase-grafana`
2+
3+
Observability for your Supabase project, using Prometheus/Grafana, collecting [~200 metrics](./docs/metrics.md):
4+
5+
![./docs/supabase-grafana-prometheus.png](./docs/supabase-grafana-prometheus.png)
6+
7+
## Getting started
8+
9+
To run the collector locally using Docker Compose
10+
11+
### Managing secrets
12+
13+
Create an `.env` file:
14+
15+
```
16+
cp .env.sample .env
17+
```
18+
19+
Fill it out with your project details. You'll need your project ref and service role key, which you can find [here](https://app.supabase.com/project/_/settings/api).
20+
21+
### Running with Docker
22+
23+
After that, simply start docker compose and you will be able to access Grafana
24+
25+
```
26+
docker compose up
27+
```
28+
29+
### Accessing the dashboard
30+
31+
Visit [localhost:8000](https://localhost:8000) and login with the credentials:
32+
33+
- Username: `admin`
34+
- Password: [the password in your `.env` file]
35+
36+
37+
## Deploying
38+
39+
Deploy this service to a server which is always running to continuously collect metrics for your Supabase project.
40+
41+
### Using Fly.io
42+
43+
You can run the collector on a free instance of [Fly.io](https://fly.io/)
44+
45+
Follow these steps:
46+
47+
1. Make sure you have the [Fly CLI](https://fly.io/docs/getting-started/installing-flyctl/) installed, and you are logged in.
48+
2. Run `fly launch` to deploy the app to Fly.
49+
3. Copy your `.env` file to your Fly project: `fly secrets set $(cat .env | xargs)`
50+
4. After a successful deployment, your app will be available at `https://<your-app-name>.fly.dev`

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "3.8"
2+
3+
services:
4+
supabase-grafana:
5+
build: ./
6+
ports:
7+
- 8000:8080
8+
environment:
9+
SUPABASE_PROJECT_REF: ${SUPABASE_PROJECT_REF}
10+
SUPABASE_SERVICE_ROLE_KEY: ${SUPABASE_SERVICE_ROLE_KEY}
11+
PASSWORD_PROTECTED: ${PASSWORD_PROTECTED}
12+
GRAFANA_PASSWORD: ${GRAFANA_PASSWORD}

0 commit comments

Comments
 (0)