Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions TEKDB/TEKDB/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions TEKDB/TEKDB/static/admin/js/admin_index.js
Original file line number Diff line number Diff line change
@@ -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.
</br><br>
This process CANNOT be undone. </br><br>
It is recommended that you use the 'Export to .zip' button above to export
Expand All @@ -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. </br><br>
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. </br><br>
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. </br><br>
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
Expand Down
2 changes: 1 addition & 1 deletion TEKDB/TEKDB/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion docker/common.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
db:
container_name: db
image: postgis/postgis:15-3.4
restart: always
platform: linux/amd64
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.prod.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions proxy/Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 11 additions & 5 deletions proxy/default.local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
82 changes: 82 additions & 0 deletions scripts/Linux/install-docker-env.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

# Install Docker packages:
echo "Installing Docker packages..."
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Verify installation:
if systemctl is-active --quiet docker; then
echo "Docker is installed and running."
else
echo "Docker installation failed or Docker is not running."
echo "Starting Docker..."
sudo systemctl start docker
if systemctl is-active --quiet docker; then
echo "Docker started successfully."
else
echo "Failed to start Docker. Please check the installation and try again."
exit 1
fi
fi

echo "Adding ubuntu user to the docker group..."
sudo usermod -aG docker ubuntu

echo "Installing git..."
sudo apt install git -y

echo "Creating TEKDB directory and cloning repository..."
mkdir tekdb
cd tekdb
git clone https://github.com/Ecotrust/TEKDB.git

# TODO: change to the main branch once the develop branch is merged into main!!
echo "Checking out the develop branch..."
cd TEKDB
git checkout develop
git pull origin develop

echo "Moving the .env.prod file to the Docker directory..."
mv $ENV_FILE docker/.env.prod

echo "Pulling the latest Docker image..."
docker pull ghcr.io/ecotrust/tekdb/web:latest

echo "Starting the Docker containers..."
docker compose --env-file docker/.env.prod -f docker/docker-compose.prod.local.yaml up -d

echo "Verifying that the containers are running..."
if [ "$(docker container inspect -f '{{.State.Status}}' "tekdb_web" 2>/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
58 changes: 58 additions & 0 deletions scripts/Linux/teardown-docker-env.sh
Original file line number Diff line number Diff line change
@@ -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."
Loading