Updates to environment variables

This commit is contained in:
Brett 2023-06-10 08:11:18 +02:00
parent 5a13a9f484
commit 969494b9aa
9 changed files with 54 additions and 37 deletions

8
.env
View File

@ -13,13 +13,17 @@ NGINX_PORT_HOST=81
NGINX_SSLPORT_HOST=8443 NGINX_SSLPORT_HOST=8443
# CKAN databases # CKAN databases
POSTGRES_USER=admindbuser POSTGRES_USER=postgres
POSTGRES_PASSWORD=admindbpassword POSTGRES_PASSWORD=admindbpassword
POSTGRES_DB=admindb
PGDATA=/var/lib/postgresql/data/db
POSTGRES_HOST=db
CKAN_DB_USER=ckandbuser CKAN_DB_USER=ckandbuser
CKAN_DB_PASSWORD=ckandbpassword CKAN_DB_PASSWORD=ckandbpassword
CKAN_DB=ckandb
DATASTORE_READONLY_USER=datastore_ro DATASTORE_READONLY_USER=datastore_ro
DATASTORE_READONLY_PASSWORD=datastore DATASTORE_READONLY_PASSWORD=datastore
POSTGRES_HOST=db DATASTORE_DB=datastore
CKAN_SQLALCHEMY_URL=postgresql://ckandbuser:ckandbpassword@db/ckandb CKAN_SQLALCHEMY_URL=postgresql://ckandbuser:ckandbpassword@db/ckandb
CKAN_DATASTORE_WRITE_URL=postgresql://ckandbuser:ckandbpassword@db/datastore CKAN_DATASTORE_WRITE_URL=postgresql://ckandbuser:ckandbpassword@db/datastore
CKAN_DATASTORE_READ_URL=postgresql://datastore_ro:datastore@db/datastore CKAN_DATASTORE_READ_URL=postgresql://datastore_ro:datastore@db/datastore

View File

@ -55,7 +55,7 @@ services:
- pg_data:/var/lib/postgresql/data - pg_data:/var/lib/postgresql/data
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "pg_isready", "-U", "admindbuser", "-d", "admindb"] test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d", "${POSTGRES_DB}"]
solr: solr:
container_name: ${SOLR_CONTAINER_NAME} container_name: ${SOLR_CONTAINER_NAME}

View File

@ -13,8 +13,8 @@ services:
context: nginx/ context: nginx/
dockerfile: Dockerfile dockerfile: Dockerfile
networks: networks:
- frontend - webnet
- backend - ckannet
depends_on: depends_on:
ckan: ckan:
condition: service_healthy condition: service_healthy
@ -29,7 +29,10 @@ services:
args: args:
- TZ=${TZ} - TZ=${TZ}
networks: networks:
- backend - ckannet
- dbnet
- solrnet
- redisnet
env_file: env_file:
- .env - .env
depends_on: depends_on:
@ -48,7 +51,8 @@ services:
datapusher: datapusher:
container_name: ${DATAPUSHER_CONTAINER_NAME} container_name: ${DATAPUSHER_CONTAINER_NAME}
networks: networks:
- backend - ckannet
- dbnet
image: ckan/ckan-base-datapusher:${DATAPUSHER_VERSION} image: ckan/ckan-base-datapusher:${DATAPUSHER_VERSION}
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
@ -58,27 +62,29 @@ services:
container_name: ${POSTGRESQL_CONTAINER_NAME} container_name: ${POSTGRESQL_CONTAINER_NAME}
build: build:
context: postgresql/ context: postgresql/
args:
- DATASTORE_READONLY_PASSWORD=${DATASTORE_READONLY_PASSWORD}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- CKAN_DB_PASSWORD=${CKAN_DB_PASSWORD}
networks: networks:
- backend - dbnet
environment: environment:
- DATASTORE_READONLY_PASSWORD=${DATASTORE_READONLY_PASSWORD} - POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
- PGDATA=${PGDATA}
- CKAN_DB_USER=${CKAN_DB_USER}
- CKAN_DB_PASSWORD=${CKAN_DB_PASSWORD} - CKAN_DB_PASSWORD=${CKAN_DB_PASSWORD}
- PGDATA=/var/lib/postgresql/data/db - CKAN_DB=${CKAN_DB}
- DATASTORE_READONLY_USER=${DATASTORE_READONLY_USER}
- DATASTORE_READONLY_PASSWORD=${DATASTORE_READONLY_PASSWORD}
- DATASTORE_DB=${DATASTORE_DB}
volumes: volumes:
- pg_data:/var/lib/postgresql/data - pg_data:/var/lib/postgresql/data
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "pg_isready", "-U", "admindbuser", "-d", "admindb"] test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d", "${POSTGRES_DB}"]
solr: solr:
container_name: ${SOLR_CONTAINER_NAME} container_name: ${SOLR_CONTAINER_NAME}
networks: networks:
- backend - solrnet
image: ckan/ckan-solr:${SOLR_IMAGE_VERSION} image: ckan/ckan-solr:${SOLR_IMAGE_VERSION}
volumes: volumes:
- solr_data:/var/solr - solr_data:/var/solr
@ -88,13 +94,16 @@ services:
redis: redis:
container_name: ${REDIS_CONTAINER_NAME} container_name: ${REDIS_CONTAINER_NAME}
networks:
- backend
image: redis:${REDIS_VERSION} image: redis:${REDIS_VERSION}
networks:
- redisnet
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "redis-cli", "-e", "QUIT"] test: ["CMD", "redis-cli", "-e", "QUIT"]
networks: networks:
frontend: webnet:
backend: ckannet:
solrnet:
dbnet:
redisnet:

View File

@ -3,12 +3,5 @@ FROM postgres:12-alpine
# Allow connections; we don't map out any ports so only linked docker containers can connect # Allow connections; we don't map out any ports so only linked docker containers can connect
RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf
# Customize default user/pass/db
ENV POSTGRES_DB admindb
ENV POSTGRES_USER admindbuser
ARG POSTGRES_PASSWORD
ARG CKAN_DB_PASSWORD
ARG DATASTORE_READONLY_PASSWORD
# Include extra setup scripts (eg datastore) # Include extra setup scripts (eg datastore)
ADD docker-entrypoint-initdb.d /docker-entrypoint-initdb.d ADD docker-entrypoint-initdb.d /docker-entrypoint-initdb.d

View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE ROLE "$CKAN_DB_USER" NOSUPERUSER CREATEDB CREATEROLE LOGIN PASSWORD '$CKAN_DB_PASSWORD';
CREATE DATABASE "$CKAN_DB" OWNER "$CKAN_DB_USER" ENCODING 'utf-8';
EOSQL

View File

@ -1,4 +0,0 @@
\set ckan_db_password '\'' `echo $CKAN_DB_PASSWORD` '\''
CREATE ROLE ckandbuser NOSUPERUSER CREATEDB CREATEROLE LOGIN PASSWORD :ckan_db_password;
CREATE DATABASE ckandb OWNER ckandbuser ENCODING 'utf-8';

View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE ROLE "$DATASTORE_READONLY_USER" NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN PASSWORD '$DATASTORE_READONLY_PASSWORD';
CREATE DATABASE "$DATASTORE_DB" OWNER "$CKAN_DB_USER" ENCODING 'utf-8';
EOSQL

View File

@ -1,4 +0,0 @@
\set datastore_ro_password '\'' `echo $DATASTORE_READONLY_PASSWORD` '\''
CREATE ROLE datastore_ro NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN PASSWORD :datastore_ro_password;
CREATE DATABASE datastore OWNER ckandbuser ENCODING 'utf-8';

View File

@ -1,2 +1,7 @@
CREATE DATABASE ckan_test OWNER ckandbuser ENCODING 'utf-8'; #!/bin/bash
CREATE DATABASE datastore_test OWNER ckandbuser ENCODING 'utf-8'; set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE DATABASE ckan_test OWNER "$CKAN_DB_USER" ENCODING 'utf-8';
CREATE DATABASE datastore_test OWNER "$CKAN_DB_USER" ENCODING 'utf-8';
EOSQL