-
-
Notifications
You must be signed in to change notification settings - Fork 128
Digital Ocean
Head over to our Digital Ocean marketplace listing and create your droplet. You are free to create one even at the most basic configuration. No restrictions for you here.
SSH into your instance using the user root and type in the following once you are in:
$ sudo -u postgres psql
This logs you into the psql terminal as the DB Superuser postgres.
Set your password with this command:
$ \password
Enter your desired password afterward and re-enter it when prompted. Once done, you can now exit your SSH connection.
With any SQL client of your choice (Such as DBeaver), connect to your database with the following credentials:
- Host: insert droplet ip address
- Port: 5432
- User: postgres
- Password: insert your chosen password
- Database: postgres
-
DO_TOKEN
,REGION
,SNAPSHOT_REGIONS
all need to be defined. A list of valid Digital Ocean regions can be found here. ForSNAPSHOT_REGIONS
, regions are all contained in a single string, separated with a comma (eg. 'fra1,nyc1,sgp1').
$ export DO_TOKEN=your_digital_ocean_token
$ export REGION=your_chosen_region
$ export SNAPSHOT_REGIONS=your_chosen_snapshot_regions
-
ANSIBLE_ARGUMENTS
by default excludes PgBouncer and PostgREST.
"--skip-tags,update-only,--skip-tags,install-postgrest,--skip-tags,install-pgbouncer,--skip-tags,install-supabase-internal"
If you want to install any of them into your image, set the value for ANSIBLE_ARGUMENTS
while omitting the following parts:
# Remove this part to install PgBouncer
"--skip-tags,install-pgbouncer"
# Remove this part to install PostgREST
"--skip-tags,install-postgrest"
$ packer build \
-var "do_token=$DO_TOKEN" \
-var "region=$REGION" \
-var "snapshot_regions=$SNAPSHOT_REGIONS" \
-var "ansible_arguments=$ANSIBLE_ARGUMENTS" \
digitalOcean.json
To be in line with the standards of images found in the Digital Ocean Marketplace, scripts found in scripts
are also ran to clean up the snapshot and make it compatible with the Marketplace. They are taken from here. More information on what these scripts achieve can be found here.
If you wish to build on top on an already existing version of Supabase Postgres, you need not build everything from scratch. You can circumvent the long build time. This utilises the tag feature of Ansible.
In the directory ansible
, you can add new tasks in playbook.yml
. You would then need to provide each of these new tasks with a tag for it to be identified. For this guide, we will use a tag named update
.
-
DO_TOKEN
,REGION
,SNAPSHOT_REGIONS
,IMAGE_NAME
andARGS
all need to be defined. A list of valid Digital Ocean regions can be found here. ForSNAPSHOT_REGIONS
, regions are all contained in a single string, separated with a comma (eg. 'fra1,nyc1,sgp1'). FORIMAGE_NAME
, the image name (supabase-supabasepostgres-18-04) of the marketplace version of Supabase Postgres should be used.
$ export DO_TOKEN=your_digital_ocean_token
$ export REGION=your_chosen_region
$ export SNAPSHOT_REGIONS=your_chosen_snapshot_regions
$ export IMAGE_NAME="supabase-supabasepostgres-18-04"
$ export ARGS="--tags,update"
Because we ultimately set the additional argument of --tags "update"
, we are signaling to Ansible to only run the tasks that have the tag update
. Everything that has already been built before are skipped. You would need to make sure however that both versions in this repository and the marketplace image of Supabase Postgres are the same. You might be skipping crucial updates otherwise.
$ packer build \
-var "do_token=$DO_TOKEN" \
-var "region=$REGION" \
-var "snapshot_regions=$SNAPSHOT_REGIONS" \
-var "image_name=$IMAGE_NAME" \
-var "ansible_arguments=$ARGS" \
digitalOcean.json
If you have a volume attached to your droplet, you can make the volume the default data directory for your Postgres server. Instructions provided are with reference to this guide.
$ sudo -u postgres psql
postgres=# SHOW data_directory;
For the current build of Supabase Postgres, this would return a path of /var/lib/postgresql/12/main
.
$ ls /mnt/
An example path that we would use for this guide will be /mnt/volume_sgp1_01
.
$ sudo systemctl stop postgresql
$ sudo rsync -av /var/lib/postgresql /mnt/volume_sgp1_01
$ sudo mv /var/lib/postgresql/12/main /var/lib/postgresql/12/main.bak
$ sudo vim /etc/postgresql/12/main/postgresql.conf
Inside the configuration, change the following:
...
data_directory = `/var/lib/postgresql/12/main`
...
to
...
data_directory = `/mnt/volume_sgp1_01/postgresql/12/main`
...
$ sudo systemctl start postgresql
- Check if Postgres is up
$ sudo systemctl status postgresql
- Check if the data directory path has been updated
$ sudo -u postgres psql
postgres=# SHOW data_directory;
At this point, this should return a path of /mnt/volume_sgp1_01/postgresql/12/main
.
- Verify the integrity of any existing data
$ sudo rm -rf /var/lib/postgresql/12/main.bak
Follow us online: supabase.io | Twitter | DEV
Subscribe to this repo to get notified when we release new builds and versions.