From 6bcdd1ed08953cda7c2325529cd842dde14fc3ca Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:41:08 +0100 Subject: [PATCH 1/2] Improve db container backups README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ed1c3471..d6b02ae8 100644 --- a/README.md +++ b/README.md @@ -554,14 +554,14 @@ PostgreSQL offers the command line tools [`pg_dump`](https://www.postgresql.org/ #### Backup service for db container 1. Create a new file called `ckan_backup_custom.sh` and open it in your preferred text editor. -2. Add the following code to the script, replacing the placeholders with your actual values: +2. Add the following code to the script, replacing the placeholders with your [`.env`](.env.example) values: ```bash #!/bin/bash # Set the necessary variables - CONTAINER_NAME="db" - DATABASE_NAME="ckandb" + DB_CONTAINER_NAME="ckan-docker-db-1" + CKAN_DB="ckandb" POSTGRES_USER="postgres" POSTGRES_PASSWORD="your_postgres_password" BACKUP_DIRECTORY="/path/to/your/backup/directory" @@ -573,7 +573,7 @@ PostgreSQL offers the command line tools [`pg_dump`](https://www.postgresql.org/ mkdir -p "$BACKUP_DIRECTORY/monthly/$YEAR-$MONTH" # Run the backup command - docker exec -e PGPASSWORD=$POSTGRES_PASSWORD $CONTAINER_NAME pg_dump -U $POSTGRES_USER -Fc $DATABASE_NAME > "$BACKUP_DIRECTORY/monthly/$YEAR-$MONTH/ckan_backup_$DATE.dump" + docker exec -e PGPASSWORD=$POSTGRES_PASSWORD $DB_CONTAINER_NAME pg_dump -U $POSTGRES_USER -Fc $CKAN_DB > "$BACKUP_DIRECTORY/monthly/$YEAR-$MONTH/ckan_backup_$DATE.dump" # Compress the dump files into a zip archive cd "$BACKUP_DIRECTORY/monthly/$YEAR-$MONTH" || exit @@ -637,7 +637,7 @@ If need to use a backup, restore it: 2. After cleaning the database you must do either [initialize it](https://docs.ckan.org/en/2.9/maintaining/database-management.html#initialization) or import a previously created dump. ```bash - docker exec -i -e PGPASSWORD=$POSTGRES_PASSWORD $POSTGRESQL_CONTAINER_NAME pg_restore -U $POSTGRES_USER --clean --if-exists -d $DATABASE_NAME < /path/to/your/backup/directory/ckan.dump + docker exec -i -e PGPASSWORD=$POSTGRES_PASSWORD $DB_CONTAINER_NAME pg_restore -U $POSTGRES_USER --clean --if-exists -d $CKAN_DB < /path/to/your/backup/directory/ckan.dump ``` 3. Restart the `ckan` container. From 33c6e23e7b04d7edcc301732e9bdf7396c5679b2 Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Fri, 8 Nov 2024 13:43:46 +0100 Subject: [PATCH 2/2] Enhance NGINX Docker setup: add landing page, update configurations, and include static files --- nginx/Dockerfile | 11 ++- nginx/setup/default.conf.template | 15 +-- nginx/setup/html/github.svg | 1 + nginx/setup/html/index.html | 155 ++++++++++++++++++++++++++++++ nginx/setup/{ => html}/robots.txt | 0 nginx/setup/index.html | 22 ----- 6 files changed, 172 insertions(+), 32 deletions(-) create mode 100644 nginx/setup/html/github.svg create mode 100644 nginx/setup/html/index.html rename nginx/setup/{ => html}/robots.txt (100%) delete mode 100644 nginx/setup/index.html diff --git a/nginx/Dockerfile b/nginx/Dockerfile index afca9823..c66209c9 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -13,13 +13,18 @@ ENV PROXY_CKAN_PROXY_PASS=http://${CKAN_COMPOSE_SERVICE}:${CKAN_PORT} ENV NGINX_PORT=80 ENV NGINX_LOG_DIR=/var/log/nginx ENV NGINX_DIR=/etc/nginx +ENV NGINX_SHARE_HTML_DIR=/usr/share/nginx/html -RUN mkdir -p ${NGINX_LOG_DIR} && \ - mkdir -p ${NGINX_DIR}/certs +RUN mkdir -p ${NGINX_LOG_DIR} \ + && mkdir -p ${NGINX_DIR}/certs +# Copy configuration and static files COPY setup/nginx.conf ${NGINX_DIR}/nginx.conf -COPY setup/index.html /usr/share/nginx/html/index.html COPY setup/default.conf.template ${NGINX_DIR}/templates/default.conf.template COPY setup/ckan-local.* ${NGINX_DIR}/certs/ +COPY setup/html/index.html setup/html/robots.txt ${NGINX_SHARE_HTML_DIR}/ + +# Replace $PROXY_CKAN_LOCATION and $PROXY_PYCSW_LOCATION in index.html +RUN sed -i "s|/catalog|${PROXY_CKAN_LOCATION}|g; s|/csw|${PROXY_PYCSW_LOCATION}|g" ${NGINX_SHARE_HTML_DIR}/index.html EXPOSE ${NGINX_PORT} \ No newline at end of file diff --git a/nginx/setup/default.conf.template b/nginx/setup/default.conf.template index d0c21a43..51c7b22e 100644 --- a/nginx/setup/default.conf.template +++ b/nginx/setup/default.conf.template @@ -7,6 +7,9 @@ server { ssl_certificate /etc/nginx/certs/ckan-local.crt; ssl_certificate_key /etc/nginx/certs/ckan-local.key; + root $NGINX_SHARE_HTML_DIR; + index index.html; + # TLS 1.2 & 1.3 only ssl_protocols TLSv1.2 TLSv1.3; @@ -70,12 +73,10 @@ server { error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /error.html; # redirect server error pages to the static page /error.html - # - location = /error.html { - ssi on; - internal; - auth_basic off; - root /usr/share/nginx/html; + + # robots.txt + location = /robots.txt { + add_header Content-Type text/plain; + root $NGINX_SHARE_HTML_DIR; } - } \ No newline at end of file diff --git a/nginx/setup/html/github.svg b/nginx/setup/html/github.svg new file mode 100644 index 00000000..a3ff759d --- /dev/null +++ b/nginx/setup/html/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/nginx/setup/html/index.html b/nginx/setup/html/index.html new file mode 100644 index 00000000..c5308a4e --- /dev/null +++ b/nginx/setup/html/index.html @@ -0,0 +1,155 @@ + + +
+ + + +