Skip to content
Open
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
2 changes: 1 addition & 1 deletion backup_db.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mkdir -p /home/incubator/dumps/$(date +"%y-%m")
docker compose -f /home/incubator/docker/apps/incubator/docker-compose.yml exec -T db pg_dumpall --username="incubator" > /home/incubator/dumps/$(date +"%y-%m")/$(date +"%y-%m-%d").sql
docker compose -f /home/incubator/docker/apps/incubator/docker-compose.yml exec -T db pg_dump --username="incubator" --dbname="incubator_db" > /home/incubator/dumps/$(date +"%y-%m")/$(date +"%y-%m-%d").sql
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

git pull
docker pull ghcr.io/urlab/incubator:main
docker-compose up -d --build
docker-compose exec web uv run python manage.py migrate --noinput
docker-compose exec web uv run python manage.py collectstatic --no-input --clear
docker-compose restart nginx
docker compose up -d --build
docker compose exec web uv run python manage.py migrate --noinput
docker compose exec web uv run python manage.py collectstatic --no-input --clear
docker compose restart nginx
8 changes: 7 additions & 1 deletion incubator/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,21 @@
DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_FROM", default="contact@urlab.be")
EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS", default=True)

DEFAULT_FILE_STORAGE = {
DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage"

STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
}

# Security settings (applied in production when DEBUG=False)
if not DEBUG:
SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
SECURE_HSTS_SECONDS = 31536000 # 1 year
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True
Expand Down
6 changes: 6 additions & 0 deletions incubator/templatetags/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,10 @@ def safe_markdown(value):
@register.filter(is_safe=False, name="unsafeMarkdown")
@stringfilter
def unsafe_markdown(value):
"""Render markdown to sanitized HTML.

Despite the name, this filter uses the same sanitized rendering path as the
``markdown`` filter via ``_render_markdown``. It is retained for backwards
compatibility with existing templates that reference ``unsafeMarkdown``.
"""
return mark_safe(_render_markdown(value))
15 changes: 10 additions & 5 deletions upgrade_postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ source .env.db
DB_NAME="${POSTGRES_DB:-incubator_db}"
DB_USER="${POSTGRES_USER:-incubator}"

# echo "[1/6] Dumping database from PostgreSQL 12..."
# docker compose exec -T db pg_dumpall -U "$DB_USER" > "$DUMP_FILE"
# DUMP_SIZE=$(du -h "$DUMP_FILE" | cut -f1)
# echo " Dump complete: $DUMP_FILE ($DUMP_SIZE)"
echo "[1/6] Dumping database from PostgreSQL 12..."
docker compose exec -T db pg_dump -U "$DB_USER" -d "$DB_NAME" > "$DUMP_FILE"
DUMP_SIZE=$(du -h "$DUMP_FILE" | cut -f1)
echo " Dump complete: $DUMP_FILE ($DUMP_SIZE)"

if [ ! -s "$DUMP_FILE" ]; then
echo "ERROR: Dump file is empty or missing. Aborting."
exit 1
fi

echo "[2/6] Stopping all services..."
docker compose down
Expand Down Expand Up @@ -65,7 +70,7 @@ for i in $(seq 1 30); do
done

echo "[6/6] Restoring dump into PostgreSQL 17..."
docker compose exec -T db psql -U "$DB_USER" -d "$DB_NAME" < "$DUMP_FILE"
docker compose exec -T db psql -U "$DB_USER" -d "$DB_NAME" -v ON_ERROR_STOP=1 < "$DUMP_FILE"

# Re-set the password so it's hashed with scram-sha-256 (Postgres 17 default).
# Old Postgres 12 stored passwords as md5, which won't work for TCP connections.
Expand Down