WSL/SLF GitLab Repository

Commit cee2906a authored by Sam's avatar Sam
Browse files

update init scripts, use postgis image, vars

parent ab6a713e
......@@ -20,11 +20,11 @@ PASSWORDHERE
**.db.secret** contains the postgres connection credentials for
the remote database (for replication), in format:
```
CKAN_DB_HOST=xxxxxx.wsl.ch
CKAN_DB_NAME=envidat
CKAN_DB_USER=xxenvidat
CKAN_DB_PASS=xxxxxx
CKAN_DOI_DB_NAME=envidat_doi
DB_HOST=xxxxxx.wsl.ch
DB_CKAN_NAME=envidat
DB_USER=xxenvidat
DB_PASS=xxxxxx
DB_DOI_NAME=envidat_doi
```
**.solr.secret** contains the credentials for setting and
......
......@@ -61,10 +61,13 @@ services:
- db_env_secret
volumes:
- pg_data:/var/lib/postgresql/data
- /etc/hosts:/etc/hosts:ro
networks:
- ckan-internal
healthcheck:
test: ["CMD", "pg_isready", "-U", "dbenvidat"]
test: ["CMD", "pg_isready", "-U", "postgres"]
ports:
- 9432:5432
solr:
container_name: ckan_solr
......
ARG EXTERNAL_REG
FROM ${EXTERNAL_REG}/postgis/postgis:12-3.1
FROM ${EXTERNAL_REG}/postgis/postgis:14-3.2
ARG MAINTAINER
LABEL maintainer="${MAINTAINER}"
......
......@@ -2,7 +2,7 @@
set -e
psql -v ON_ERROR_STOP=1 --username postgres --dbname postgres <<-EOSQL
CREATE ROLE $CKAN_DB_USER WITH
CREATE ROLE $DB_USER WITH
NOSUPERUSER
NOCREATEDB
NOCREATEROLE
......@@ -10,7 +10,7 @@ psql -v ON_ERROR_STOP=1 --username postgres --dbname postgres <<-EOSQL
LOGIN
NOREPLICATION
NOBYPASSRLS
PASSWORD '$CKAN_DB_PASS';
CREATE DATABASE $CKAN_DB_NAME WITH OWNER=$CKAN_DB_USER;
CREATE DATABASE $CKAN_DOI_DB_NAME WITH OWNER=$CKAN_DB_USER;
PASSWORD '$DB_PASS';
CREATE DATABASE $DB_CKAN_NAME WITH OWNER=$DB_USER;
CREATE DATABASE $DB_DOI_NAME WITH OWNER=$DB_USER;
EOSQL
\ No newline at end of file
#!/bin/bash
set -e
PGPASSWORD="$CKAN_DB_PASS" pg_dump -C --format c \
--host "$CKAN_DB_HOST" --username "$CKAN_DB_USER" \
"$CKAN_DB_NAME" | \
pg_restore --exit-on-error \
--username postgres --dbname "$CKAN_DB_NAME"
echo "Backup and restoring $DB_CKAN_NAME via pipe to new host."
PGPASSWORD="$DB_PASS" pg_dump --verbose --format c \
--host "$DB_HOST" --username "$DB_USER" "$DB_CKAN_NAME" \
| pg_restore --verbose --exit-on-error \
--username postgres --dbname postgres
PGPASSWORD="$CKAN_DB_PASS" pg_dump -C --format c \
--host "$CKAN_DB_HOST" --username "$CKAN_DB_USER" \
"$CKAN_DOI_DB_NAME" | \
pg_restore --exit-on-error \
--username postgres --dbname "$CKAN_DOI_DB_NAME"
echo "Backup and restoring $DB_DOI_NAME via pipe to new host."
PGPASSWORD="$DB_PASS" pg_dump --verbose --format c \
--host "$DB_HOST" --username "$DB_USER" "$DB_DOI_NAME" \
| pg_restore --verbose --exit-on-error \
--username postgres --dbname postgres
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username postgres --dbname "$CKAN_DB_NAME" <<-EOSQL
psql -v ON_ERROR_STOP=1 --username postgres --dbname postgres <<-EOSQL
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;
ALTER VIEW geometry_columns OWNER TO "$CKAN_DB_USER";
ALTER TABLE spatial_ref_sys OWNER TO "$CKAN_DB_USER";
ALTER VIEW geometry_columns OWNER TO "$DB_USER";
ALTER TABLE spatial_ref_sys OWNER TO "$DB_USER";
EOSQL
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment