Simplified the DB creation process by running a postgres container directly
parent
1bdcc2fd83
commit
9b26cd99df
@ -1,7 +0,0 @@
|
|||||||
FROM youainti/aact_from_dump
|
|
||||||
LABEL AUTHOR 'Will King (youainti@protonmail.com)'
|
|
||||||
LABEL DESCRIPTION 'add extra processing to the aact database in preparation for downloading history.'
|
|
||||||
|
|
||||||
#copy additional init scripts
|
|
||||||
COPY ./docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/
|
|
||||||
#these will be run after the database is initialized
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
--Create ctti user and grant permissions
|
||||||
|
CREATE ROLE ctti;
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE aact_db TO ctti;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Add the root user if it doesn't exist.
|
||||||
|
With the default configuration this shouldn't be an issue,
|
||||||
|
but I can see myself forgetting and changing the default POSTGRES_USER
|
||||||
|
*/
|
||||||
|
DO LANGUAGE plpgsql
|
||||||
|
$do$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT FROM pg_catalog.pg_roles -- SELECT list can be empty for this
|
||||||
|
WHERE rolname = 'root')
|
||||||
|
THEN
|
||||||
|
CREATE ROLE root LOGIN PASSWORD 'root'; --SECURITY ISSUE
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE aact_db TO root;
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$do$
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
|
||||||
|
# This file loads the database dump into the postgres database
|
||||||
|
|
||||||
|
dump_path="/mnt/host_data/postgres_data.dmp"
|
||||||
|
|
||||||
|
#Double check the postgres user and database are set
|
||||||
|
if [[ -z $POSTGRES_USER && -z $POSTGRES_DB ]]; #if either POSTGRES_USER or POSTGRES_DB are empty, throw an error.
|
||||||
|
then
|
||||||
|
echo "Missing either the POSTGRESS_USER or the POSTGRES_DB environment variable"
|
||||||
|
exit 4
|
||||||
|
else
|
||||||
|
#restore the DB
|
||||||
|
pg_restore -e -v -O -x --dbname="$POSTGRES_DB" --username="$POSTGRES_USER" --no-owner "$dump_path"
|
||||||
|
fi
|
||||||
@ -1 +0,0 @@
|
|||||||
This is what is needed to setup the database.
|
|
||||||
Loading…
Reference in New Issue