Skip to content

Commit dedfb43

Browse files
authored
Merge pull request supabase#44 from supabase/feature/supabasePostgresV1.0
Major Upgrading of Supabase Postgres
2 parents 54c990d + 90f0ba0 commit dedfb43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2420
-795
lines changed

.github/workflows/provision.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

README.md

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,44 @@
22

33
Unmodified Postgres with some useful plugins. Our goal with this repo is not to modify Postgres, but to provide some of the most common extensions with a one-click install.
44

5-
## Features
6-
7-
- ✅ Postgres [12](https://www.postgresql.org/about/news/1976/). Includes [generated columns](https://www.postgresql.org/docs/12/ddl-generated-columns.html) and [JSON path](https://www.postgresql.org/docs/12/functions-json.html#FUNCTIONS-SQLJSON-PATH) support.
8-
- ✅ Ubuntu 18.04 (Bionic).
9-
-[pg-contrib-12](https://www.postgresql.org/docs/12/contrib.html). Because everyone should enable `pg_stat_statements`.
5+
## Primary Features
6+
- ✅ Postgres [13](https://www.postgresql.org/about/news/postgresql-13-released-2077/).
7+
- ✅ Ubuntu 20.04 (Focal Fossa).
108
-[wal_level](https://www.postgresql.org/docs/current/runtime-config-wal.html) = logical and [max_replication_slots](https://www.postgresql.org/docs/current/runtime-config-replication.html) = 5. Ready for replication.
11-
-[PostGIS](https://postgis.net/). Postgres' most popular extension - support for geographic objects.
12-
-[pgTAP](https://pgtap.org/). Unit Testing for Postgres.
13-
-[pgAudit](https://www.pgaudit.org/). Generate highly compliant audit logs.
14-
-[pgjwt](https://github.com/michelp/pgjwt). Generate JSON Web Tokens (JWT) in Postgres.
15-
-[pgsql-http](https://github.com/pramsey/pgsql-http). HTTP client for Postgres.
16-
-[plpgsql_check](https://github.com/okbob/plpgsql_check). Linter tool for PL/pgSQL.
17-
-[plv8](https://github.com/plv8/plv8). Write in Javascript functions in Postgres.
18-
-[PL/Java](https://github.com/tada/pljava). Write in Java functions in Postgres.
19-
-[pg_cron](https://github.com/citusdata/pg_cron). Run CRON jobs inside Postgres.
20-
-[pg-safeupdate](https://github.com/eradman/pg-safeupdate). Protect your data from accidental updates or deletes.
21-
-[wal2json](https://github.com/eulerto/wal2json). JSON output plugin for logical replication decoding
9+
-[Large Systems Extensions](https://github.com/aws/aws-graviton-getting-started#building-for-graviton-and-graviton2). Enabled for ARM images.
10+
11+
## Extensions
12+
| Extension | Description |
13+
| ------------- | ------------- |
14+
| [Postgres contrib modules](https://www.postgresql.org/docs/current/contrib.html) | Because everyone should enable `pg_stat_statements`. |
15+
| [PostGIS](https://postgis.net/) | Postgres' most popular extension - support for geographic objects. |
16+
| [pgRouting](https://pgrouting.org/) | Extension of PostGIS - provides geospatial routing functionalities. |
17+
| [pgTAP](https://pgtap.org/) | Unit Testing for Postgres. |
18+
| [pg_cron](https://github.com/citusdata/pg_cron) | Run CRON jobs inside Postgres. |
19+
| [pgAudit](https://www.pgaudit.org/) | Generate highly compliant audit logs. |
20+
| [pgjwt](https://github.com/michelp/pgjwt) | Generate JSON Web Tokens (JWT) in Postgres. |
21+
| [pgsql-http](https://github.com/pramsey/pgsql-http) | HTTP client for Postgres. |
22+
| [plpgsql_check](https://github.com/okbob/plpgsql_check) | Linter tool for PL/pgSQL. |
23+
| [pg-safeupdate](https://github.com/eradman/pg-safeupdate) | Protect your data from accidental updates or deletes. |
24+
| [wal2json](https://github.com/eulerto/wal2json) | JSON output plugin for logical replication decoding. |
25+
| [PL/Java](https://github.com/tada/pljava) | Write in Java functions in Postgres. |
26+
| [plv8](https://github.com/plv8/plv8) | Write in Javascript functions in Postgres. |
27+
28+
Can't find your favorite extension? Suggest for it to be added into future versions [here](https://github.com/supabase/supabase/discussions/679)!
29+
30+
## Enhanced Security
31+
Aside from having [ufw](https://help.ubuntu.com/community/UFW),[fail2ban](https://www.fail2ban.org/wiki/index.php/Main_Page), and [unattended-upgrades](https://wiki.debian.org/UnattendedUpgrades) installed, we also have the following enhancements in place:
32+
| Enhancement | Description |
33+
| ------------- | ------------- |
34+
| fail2ban filter for PostgreSQL access | Monitors for brute force attempts over at port `5432`. |
35+
| fail2ban filter for PgBouncer access | Monitors for brute force attempts over at port `6543`. |
36+
37+
## Additional Goodies
38+
| Goodie | Description |
39+
| ------------- | ------------- |
40+
| [PgBouncer](https://postgis.net/) | Set up Connection Pooling. |
41+
| [PostgREST](https://postgrest.org/en/stable/) | Instantly transform your database into an RESTful API. |
42+
| [WAL-G](https://github.com/wal-g/wal-g#wal-g) | Tool for physical database backup and recovery. |
2243

2344
## Install
2445

@@ -28,19 +49,29 @@ See all installation instructions in the [repo wiki](https://github.com/supabase
2849
[![Digital Ocean](https://github.com/supabase/postgres/blob/master/docs/img/digital-ocean.png)](https://github.com/supabase/postgres/wiki/Digital-Ocean)
2950
[![AWS](https://github.com/supabase/postgres/blob/master/docs/img/aws.png)](https://github.com/supabase/postgres/wiki/AWS-EC2)
3051

31-
### Building
32-
33-
Install the anxs.postgresql role
52+
### Marketplace Images
53+
| | Postgres & Extensions | PgBouncer | PostgREST | WAL-G |
54+
|---|:---:|:---:|:---:|:---:|
55+
| Supabase Postgres | ✔️ ||| ✔️ |
56+
| Supabase Postgres: PgBouncer Bundle | ✔️ | ✔️ || ✔️ |
57+
| Supabase Postgres: PostgREST Bundle | ✔️ || ✔️ | ✔️ |
58+
| Supabase Postgres: Complete Bundle | ✔️ | ✔️ | ✔️ | ✔️ |
3459

35-
```bash
36-
ansible-galaxy install anxs.postgresql -r ansible/install_roles.yml --force -vvv
37-
```
60+
#### Availability
61+
| | AWS ARM | AWS x86 | Digital Ocean x86 |
62+
|---|:---:|:---:|:---:|
63+
| Supabase Postgres | Coming Soon | Coming Soon | Coming Soon |
64+
| Supabase Postgres: PgBouncer Bundle | Coming Soon | Coming Soon | Coming Soon |
65+
| Supabase Postgres: PostgREST Bundle | Coming Soon | Coming Soon | Coming Soon |
66+
| Supabase Postgres: Complete Bundle | Coming Soon | Coming Soon | Coming Soon |
3867

39-
Set the `supabase_internal` flag to `false` to avoid baking in components that are specific to Supabase's hosted offering.
68+
### Quick Build
4069

4170
```bash
4271
$ time packer build -timestamp-ui \
43-
-var "ansible_arguments=--skip-tags,update-only,-v,-e,supabase_internal='false'" \
72+
--var "aws_access_key=<insert aws access key>" \
73+
--var "aws_secret_key=<insert aws secret key>" \
74+
--var "ami_regions=<insert desired regions>" \
4475
amazon-arm.json
4576
```
4677

amazon-arm.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"aws_secret_key": "",
55
"region": "ap-northeast-1",
66
"ami_regions": "eu-central-1,eu-west-1,eu-west-2,ap-south-1,ap-southeast-1,ap-southeast-2,us-west-1,us-east-1,ca-central-1,sa-east-1,ap-northeast-1",
7-
"ami": "ami-0d24b4f369844fc54",
8-
"ami_name": "supabase-postgres-0.16.2",
7+
"ami": "ami-076d8ebdd0e1ec091",
8+
"ami_name": "supabase-postgres-13.3.0",
99
"environment": "prod",
10-
"ansible_arguments": "--skip-tags,update-only -v"
10+
"ansible_arguments": "--skip-tags,update-only,--skip-tags,install-postgrest,--skip-tags,install-pgbouncer,--skip-tags,install-supabase-internal"
1111
},
1212
"builders": [
1313
{
@@ -17,7 +17,7 @@
1717
"region": "{{user `region`}}",
1818
"ami_regions": "{{user `ami_regions`}}",
1919
"source_ami": "{{user `ami`}}",
20-
"instance_type": "c6g.2xlarge",
20+
"instance_type": "r6g.2xlarge",
2121
"ssh_username": "ubuntu",
2222
"ami_name": "{{user `ami_name`}}",
2323
"tags": {
@@ -51,7 +51,6 @@
5151
"execute_command": "echo 'packer' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'",
5252
"type": "shell",
5353
"scripts": [
54-
"scripts/01-test",
5554
"scripts/02-credentials_cleanup.sh",
5655
"scripts/90-cleanup.sh",
5756
"scripts/91-log_cleanup.sh"

amazon.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"aws_secret_key": "",
55
"region": "af-south-1",
66
"ami_regions": "af-south-1",
7-
"ami": "ami-07d30d5bf2d29a582",
8-
"ami_name": "supabase-postgres-0.16.2",
7+
"ami": "ami-08a4b40f2fe1e4b35",
8+
"ami_name": "supabase-postgres-13.3.0.4",
99
"environment": "prod",
10-
"ansible_arguments": "--skip-tags,update-only"
10+
"ansible_arguments": "--skip-tags,update-only,--skip-tags,install-postgrest,--skip-tags,install-pgbouncer,--skip-tags,install-supabase-internal"
1111
},
1212
"builders": [
1313
{

ansible/files/docker_mnt/init.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cat /etc/postgresql/postgresql.conf > $PGDATA/postgresql.conf
2+
echo "host replication $POSTGRES_USER 0.0.0.0/0 trust" >> $PGDATA/pg_hba.conf
3+
echo "host all all 127.0.0.1/32 trust" >> $PGDATA/pg_hba.conf
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Definition]
2+
failregex = ^.+@<HOST>:.+error: password authentication failed$
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Definition]
2+
failregex = ^.*,.*,.*,.*,"<HOST>:.*password authentication failed for user.*$
3+
ignoreregex = ^.*,.*,.*,.*,"127\.0\.0\.1.*password authentication failed for user.*$
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[pgbouncer]
2+
enabled = true
3+
port = 6543
4+
protocol = tcp
5+
filter = pgbouncer
6+
logpath = /var/log/pgbouncer.log
7+
maxretry = 3
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[postgresql]
2+
enabled = true
3+
port = 5432
4+
protocol = tcp
5+
filter = postgresql
6+
logpath = /var/lib/postgresql/data/pg_log/postgresql.csv
7+
maxretry = 3

ansible/files/logrotate-postgres

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/var/lib/postgresql/12/main/pg_log/postgresql.csv {
2-
daily
3-
size 50M
1+
/var/lib/postgresql/data/pg_log/postgresql.log {
2+
size 50M
43
rotate 3
54
copytruncate
65
delaycompress
76
compress
87
notifempty
98
missingok
10-
}
9+
}

0 commit comments

Comments
 (0)