docker: fix data persistence with TINYWEB_DATA_DIR env var

This commit is contained in:
blankie 2026-06-14 07:48:34 +00:00
parent 27147bd3f9
commit 1461c62c91
4 changed files with 4 additions and 5 deletions

View file

@ -13,9 +13,7 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . . COPY . .
RUN mkdir -p /data \ RUN mkdir -p /data
&& ln -sf /data/index.db index.db \
&& ln -sf /data/tinyweb_identity tinyweb_identity
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1

2
app.py
View file

@ -16,7 +16,7 @@ from gateway import GatewayState, GatewayHandler
IDENTITY_FILE = "tinyweb_identity" IDENTITY_FILE = "tinyweb_identity"
DEFAULT_TRANSPORT_HOST = "rnode.bre.land" DEFAULT_TRANSPORT_HOST = "rnode.bre.land"
DEFAULT_TRANSPORT_PORT = 4242 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(): def get_transport_config():

2
db.py
View file

@ -6,7 +6,7 @@ import os
from urllib.parse import urlparse, urljoin, parse_qs, urlencode, urlunparse, quote from urllib.parse import urlparse, urljoin, parse_qs, urlencode, urlunparse, quote
from bs4 import BeautifulSoup 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") DATABASE = os.path.join(DATA_DIR, "index.db")
BLOCKED_NETWORKS = [ BLOCKED_NETWORKS = [

View file

@ -29,6 +29,7 @@ if [ ! -f "$CONFIG_FILE" ]; then
EOF EOF
fi fi
export TINYWEB_DATA_DIR="/data"
export RNS_CONFIG_DIR="$CONFIG_DIR" export RNS_CONFIG_DIR="$CONFIG_DIR"
# Bind to 0.0.0.0 inside the container; isolation is handled by Docker's port mapping. # 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 "$@" exec python app.py --bind 0.0.0.0 "$@"