diff --git a/TEKDB/TEKDB/settings.py b/TEKDB/TEKDB/settings.py index f89db7c9..762a84d9 100644 --- a/TEKDB/TEKDB/settings.py +++ b/TEKDB/TEKDB/settings.py @@ -262,7 +262,7 @@ TINYMCE_FILEBROWSER = False # Add Version to the admin site header -VERSION = "2.13.0" +VERSION = "2.13.1" ADMIN_SITE_HEADER = os.environ.get( "ADMIN_SITE_HEADER", default="ITK DB Admin v{}".format(VERSION) ) @@ -413,9 +413,4 @@ try: from TEKDB.local_settings import * # noqa: F403 except Exception: - import sys - - print( - "ERROR: Unable to load local_settings.py. This is expected for docker deployment", - file=sys.stderr, - ) + pass diff --git a/TEKDB/TEKDB/static/admin/js/admin_index.js b/TEKDB/TEKDB/static/admin/js/admin_index.js index 98485d93..f61d17e5 100644 --- a/TEKDB/TEKDB/static/admin/js/admin_index.js +++ b/TEKDB/TEKDB/static/admin/js/admin_index.js @@ -1,6 +1,6 @@ const importText = ` This process will remove all data and files from your current - database and replace it with data from the provided zip file. + database and replace it with data from the provided zipfile.

This process CANNOT be undone.

It is recommended that you use the 'Export to .zip' button above to export @@ -14,7 +14,7 @@ const importText = ` `; const importInfoText = `The Import Database Tool is designed to support restoring your Traditional Knowledge Database back to a prior state. This is best used in conjunction with the 'Export Database' tool above.

- To use the Import Database tool is simple: select a properly formatted zip file to upload and then click 'Import'. All of your data will be reverted back to the state it was when that zipfile was created.

+ To use the Import Database tool is simple: select a properly formatted zipfile to upload and then click 'Import'. All of your data will be reverted back to the state it was when that zipfile was created.

This is VERY DANGEROUS! For this to work, all of the data currently in your database, including your users, your records, and your page contents will be removed, and then replaced. Also, any files diff --git a/TEKDB/TEKDB/views.py b/TEKDB/TEKDB/views.py index 0ca76b94..9fa04bba 100644 --- a/TEKDB/TEKDB/views.py +++ b/TEKDB/TEKDB/views.py @@ -245,7 +245,7 @@ def ImportDatabase(request): # Validate Zip Contents if not len(non_media) == 1 or len(zip.namelist()) < 2: status_code = 500 - status_message = "Received malformed import file. Must be a zipfile contailing one JSON file and a directory named 'media'" + status_message = "Received malformed import file. Must be a zipfile containing one JSON file and a directory named 'media'" return JsonResponse( { "status_code": status_code, diff --git a/docker/common.yaml b/docker/common.yaml index 67297f73..52f75c17 100644 --- a/docker/common.yaml +++ b/docker/common.yaml @@ -1,5 +1,6 @@ services: db: + container_name: db image: postgis/postgis:15-3.4 restart: always platform: linux/amd64 @@ -18,8 +19,10 @@ services: timeout: 5s retries: 5 redis: + container_name: redis image: redis:alpine web: + container_name: tekdb_web build: context: ../TEKDB/ dockerfile: ../TEKDB/Dockerfile @@ -37,7 +40,8 @@ services: retries: 5 start_period: 30s - celery: + celery: + container_name: tekdb_celery entrypoint: [] command: celery -A TEKDB worker -l info environment: @@ -50,6 +54,7 @@ services: redis: condition: service_started celery-beat: + container_name: tekdb_celery_beat entrypoint: [] command: celery -A TEKDB beat -l info environment: diff --git a/docker/docker-compose.prod.local.yaml b/docker/docker-compose.prod.local.yaml index 70ea3133..8bc64b8c 100644 --- a/docker/docker-compose.prod.local.yaml +++ b/docker/docker-compose.prod.local.yaml @@ -30,7 +30,7 @@ services: depends_on: - web ports: - - "8080:8080" + - "80:8080" volumes: - static_volume:/vol/static/static:ro - media_volume:/vol/static/media:ro diff --git a/proxy/Dockerfile.local b/proxy/Dockerfile.local index 16e53fe2..6bd200e4 100644 --- a/proxy/Dockerfile.local +++ b/proxy/Dockerfile.local @@ -2,10 +2,10 @@ FROM nginxinc/nginx-unprivileged:1-alpine USER root -COPY ./default.local.conf /etc/nginx/templates/default.local.conf +COPY ./default.local.conf /etc/nginx/conf.d/default.conf COPY ./uwsgi_params /etc/nginx/uwsgi_params -RUN chmod 644 /etc/nginx/templates/default.local.conf /etc/nginx/uwsgi_params && \ +RUN chmod 644 /etc/nginx/conf.d/default.conf /etc/nginx/uwsgi_params && \ mkdir -p /vol/static && \ chmod 755 /vol/static diff --git a/proxy/default.local.conf b/proxy/default.local.conf index 23767951..8d99b56e 100644 --- a/proxy/default.local.conf +++ b/proxy/default.local.conf @@ -9,13 +9,19 @@ server { alias /vol/static/media; } location /import_database/ { - uwsgi_request_buffering off; - uwsgi_pass web:8000; - include /etc/nginx/uwsgi_params; + proxy_request_buffering off; + proxy_pass http://web:8000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } location / { - uwsgi_pass web:8000; - include /etc/nginx/uwsgi_params; + proxy_pass http://web:8000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; } } \ No newline at end of file diff --git a/scripts/Linux/install-docker-env.sh b/scripts/Linux/install-docker-env.sh new file mode 100644 index 00000000..337d70ca --- /dev/null +++ b/scripts/Linux/install-docker-env.sh @@ -0,0 +1,82 @@ +#!/bin/bash +ENV_FILE="${1:-.env.prod}" + +if [ ! -f "$ENV_FILE" ]; then + echo "Environment file $ENV_FILE not found!" + exit 1 +fi + +# Add Docker’s official GPG Key: +echo "Adding Docker's official GPG key..." +sudo apt update +sudo apt install ca-certificates curl +sudo install -m 0755 -d /etc/apt/keyrings +sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc +sudo chmod a+r /etc/apt/keyrings/docker.asc + +# Add the repository to apt sources: +echo "Adding Docker's official repository..." +sudo tee /etc/apt/sources.list.d/docker.sources </dev/null)" = "running" ]; then + echo "TEKDB containers are running successfully." +else + echo "Failed to start TEKDB containers. Please check the Docker logs for more information." + exit 1 +fi +exit 0 \ No newline at end of file diff --git a/scripts/Linux/teardown-docker-env.sh b/scripts/Linux/teardown-docker-env.sh new file mode 100755 index 00000000..c8983bfd --- /dev/null +++ b/scripts/Linux/teardown-docker-env.sh @@ -0,0 +1,58 @@ +#!/bin/bash +set -euo pipefail + +ENV_FILE="${1:-docker/.env.prod}" +COMPOSE_FILE="${2:-docker/docker-compose.prod.local.yaml}" + +REMOVE_VOLUMES="${REMOVE_VOLUMES:-0}" +REMOVE_IMAGES="${REMOVE_IMAGES:-0}" + +# Optional flags can be passed after positional args. +# --volumes => remove named/anonymous volumes +# --rmi-local => remove images built locally by compose +shift $(( $# > 2 ? 2 : $# )) || true +for arg in "$@"; do + case "$arg" in + --volumes) + REMOVE_VOLUMES=1 + ;; + --rmi-local) + REMOVE_IMAGES=1 + ;; + *) + echo "Unknown option: $arg" + echo "Usage: $0 [env_file] [compose_file] [--volumes] [--rmi-local]" + exit 1 + ;; + esac +done + +if ! command -v docker >/dev/null 2>&1; then + echo "Docker CLI not found. Install Docker first." + exit 1 +fi + +if [ ! -f "$ENV_FILE" ]; then + echo "Environment file not found: $ENV_FILE" + exit 1 +fi + +if [ ! -f "$COMPOSE_FILE" ]; then + echo "Compose file not found: $COMPOSE_FILE" + exit 1 +fi + +echo "Stopping and removing TEKDB containers..." +DOWN_CMD=(docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" down) + +if [ "$REMOVE_VOLUMES" = "1" ]; then + DOWN_CMD+=(--volumes) +fi + +if [ "$REMOVE_IMAGES" = "1" ]; then + DOWN_CMD+=(--rmi local) +fi + +"${DOWN_CMD[@]}" + +echo "TEKDB stack has been brought down successfully." \ No newline at end of file