Marketplace
Databases

PostgreSQL

Standalone PostgreSQL 16, tuned for remote access.

Deploy this app

About

Installs PostgreSQL from the official PGDG apt repository and configures it to accept connections from your private network with a generated password for the postgres role.

Restrict the firewall's source CIDR to your own private subnet. Password is in /root/postgresql-credentials.txt.

Ports opened by the installer

5432/tcp · PostgreSQL

Install script (runs as cloud-init user-data on first boot)

#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get install -y curl ca-certificates gnupg
install -d /usr/share/postgresql-common/pgdg
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc
. /etc/os-release
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main" > /etc/apt/sources.list.d/pgdg.list
apt-get update -y
apt-get install -y postgresql
DB_PASS=$(openssl rand -base64 18 | tr -dc 'A-Za-z0-9')
su - postgres -c "psql -c \"ALTER USER postgres WITH PASSWORD '$DB_PASS';\""
PGVER=$(ls /etc/postgresql)
echo "host all all 10.0.0.0/8 md5" >> /etc/postgresql/$PGVER/main/pg_hba.conf
sed -i "s/^#listen_addresses.*/listen_addresses = '*'/" /etc/postgresql/$PGVER/main/postgresql.conf
systemctl restart postgresql
echo "postgres password: $DB_PASS" > /root/postgresql-credentials.txt