feat: Switch to postgres

Migrate from MariaDB to PostgreSQL.

Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-11-30 15:13:42 +01:00
parent eca8bbf515
commit 122df968dc
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
64 changed files with 1467 additions and 1441 deletions

34
docker/postgres-entrypoint.sh Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
set -eou pipefail
PGDATA=/var/lib/postgres/data
DATABASE="aurweb"
# Initialize and setup postgres
if [ ! -f "$PGDATA/../init" ]; then
echo "Preparing postgres instance..."
touch $PGDATA/../init
# Init db directory
su postgres -c "pg_ctl initdb -D $PGDATA"
su postgres -c "echo \"listen_addresses='*'\" >> $PGDATA/postgresql.conf"
su postgres -c "echo \"host all all 0.0.0.0/0 scram-sha-256\" >> $PGDATA/pg_hba.conf"
install -d -o postgres -g postgres /run/postgresql
# Start postgres
su postgres -c "pg_ctl start -D $PGDATA"
# Configure database & user
echo "Taking care of primary database '$DATABASE'..."
su postgres -c "psql -c \"create database $DATABASE;\""
su postgres -c "psql -c \"create role aur superuser login password 'aur';\"";
# Provision database
python -m aurweb.initdb 2>/dev/null || /bin/true
# Stop postgres
su postgres -c "pg_ctl stop -D $PGDATA"
fi
exec "$@"