Set up Postgres server for friends

This commit is contained in:
Matthew Lopez
2023-12-20 12:53:29 -05:00
parent 59924e7772
commit 7eb5108a47
5 changed files with 52 additions and 0 deletions

View File

@@ -137,6 +137,38 @@ services:
networks:
internal:
postgres:
image: postgres:alpine
depends_on:
- coredns
volumes:
- type: volume
source: postgres-database
target: /var/lib/postgresql/data
- type: bind
source: ./config/postgres-init.sh
target: /docker-entrypoint-initdb.d/postgres-init.sh
env_file:
- ./environment/postgres.env
- ./environment/postgres.local.env
dns: 172.20.0.2
networks:
internal:
adminer:
image: adminer:latest
depends_on:
- coredns
- postgres
ports:
# For the Adminer web interface
- 127.0.0.1:8091:8080
env_file:
- ./environment/adminer.env
dns: 172.20.0.2
networks:
internal:
account:
build: ./repos/account
depends_on:
@@ -182,6 +214,7 @@ volumes:
minio-s3-data:
redis-data:
maildev-mail:
postgres-database:
account-certificates:
networks:

12
config/postgres-init.sh Normal file
View File

@@ -0,0 +1,12 @@
#! /bin/sh
set -eu
databases="friends"
for database in $databases; do
echo "Creating database: $database"
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE DATABASE $database;
EOSQL
done

1
environment/adminer.env Normal file
View File

@@ -0,0 +1 @@
ADMINER_DEFAULT_SERVER=postgres

1
environment/postgres.env Normal file
View File

@@ -0,0 +1 @@
POSTGRES_USER=postgres_pretendo

View File

@@ -28,6 +28,11 @@ echo "MINIO_ROOT_PASSWORD=$minio_secret_key" >>./minio.local.env
mongo_express_password=$(openssl rand -base64 32)
echo "ME_CONFIG_BASICAUTH_PASSWORD=$mongo_express_password" >>./mongo-express.local.env
# Generate a password for Postgres
postgres_password=$(openssl rand -base64 32)
echo "POSTGRES_PASSWORD=$postgres_password" >>./postgres.local.env
echo "PN_FRIENDS_CONFIG_DATABASE_URI=postgres://postgres_pretendo:$postgres_password@postgres/friends?sslmode=disable" >>./friends.local.env
# Get the Wii U IP address
printf "Enter your Wii U's IP address: "
read -r wiiu_ip