diff --git a/Dockerfile b/Dockerfile index e3b446a..4a74f83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,13 @@ -FROM nginx:1.19.8-alpine +FROM postgres:12-alpine -ENV NGINX_DIR=/etc/nginx +# 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 -COPY index.html /usr/share/nginx/html/index.html +# Customize default user/pass/db +ENV POSTGRES_DB ckan +ENV POSTGRES_USER ckan +ARG POSTGRES_PASSWORD +ARG DATASTORE_READONLY_PASSWORD -RUN mkdir -p ${NGINX_DIR}/sites-available -RUN mkdir -p ${NGINX_DIR}/sites-enabled - -COPY setup/nginx.conf ${NGINX_DIR} -COPY setup/sites-available/* ${NGINX_DIR}/sites-available - -RUN ln -s ${NGINX_DIR}/sites-available/ckan.conf ${NGINX_DIR}/sites-enabled/ckan.conf - -EXPOSE 80 \ No newline at end of file +# Include datastore setup scripts +COPY ./postgresql/docker-entrypoint-initdb.d /docker-entrypoint-initdb.d \ No newline at end of file diff --git a/docker-entrypoint-initdb.d/10_create_datastore.sql b/docker-entrypoint-initdb.d/10_create_datastore.sql new file mode 100755 index 0000000..87529ce --- /dev/null +++ b/docker-entrypoint-initdb.d/10_create_datastore.sql @@ -0,0 +1,4 @@ +\set datastore_ro_password '\'' `echo $DATASTORE_READONLY_PASSWORD` '\'' + +CREATE ROLE datastore_ro NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN PASSWORD :datastore_ro_password; +CREATE DATABASE datastore OWNER ckan ENCODING 'utf-8'; \ No newline at end of file diff --git a/docker-entrypoint-initdb.d/20_setup_test_databases.sql b/docker-entrypoint-initdb.d/20_setup_test_databases.sql new file mode 100755 index 0000000..61366d2 --- /dev/null +++ b/docker-entrypoint-initdb.d/20_setup_test_databases.sql @@ -0,0 +1,2 @@ +CREATE DATABASE ckan_test OWNER ckan ENCODING 'utf-8'; +CREATE DATABASE datastore_test OWNER ckan ENCODING 'utf-8'; \ No newline at end of file