From 1461c62c9151b1c4e3f8ee105ae7487a07b52c01 Mon Sep 17 00:00:00 2001 From: blankie Date: Sun, 14 Jun 2026 07:48:34 +0000 Subject: [PATCH] docker: fix data persistence with TINYWEB_DATA_DIR env var --- Dockerfile | 4 +--- app.py | 2 +- db.py | 2 +- entrypoint.sh | 1 + 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 713df67..3f73263 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,7 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . -RUN mkdir -p /data \ - && ln -sf /data/index.db index.db \ - && ln -sf /data/tinyweb_identity tinyweb_identity +RUN mkdir -p /data ENV PYTHONUNBUFFERED=1 diff --git a/app.py b/app.py index 6e70196..035eca0 100644 --- a/app.py +++ b/app.py @@ -16,7 +16,7 @@ from gateway import GatewayState, GatewayHandler IDENTITY_FILE = "tinyweb_identity" DEFAULT_TRANSPORT_HOST = "rnode.bre.land" DEFAULT_TRANSPORT_PORT = 4242 -DATA_DIR = os.path.expanduser("~/.tinyweb") +DATA_DIR = os.environ.get("TINYWEB_DATA_DIR") or os.path.expanduser("~/.tinyweb") def get_transport_config(): diff --git a/db.py b/db.py index ec13254..97378d9 100644 --- a/db.py +++ b/db.py @@ -6,7 +6,7 @@ import os from urllib.parse import urlparse, urljoin, parse_qs, urlencode, urlunparse, quote from bs4 import BeautifulSoup -DATA_DIR = os.path.expanduser("~/.tinyweb") +DATA_DIR = os.environ.get("TINYWEB_DATA_DIR") or os.path.expanduser("~/.tinyweb") DATABASE = os.path.join(DATA_DIR, "index.db") BLOCKED_NETWORKS = [ diff --git a/entrypoint.sh b/entrypoint.sh index 7385146..b741c4c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,6 +29,7 @@ if [ ! -f "$CONFIG_FILE" ]; then EOF fi +export TINYWEB_DATA_DIR="/data" export RNS_CONFIG_DIR="$CONFIG_DIR" # Bind to 0.0.0.0 inside the container; isolation is handled by Docker's port mapping. exec python app.py --bind 0.0.0.0 "$@"