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 af6ad6d391
commit 71c1175df8
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 . .
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

2
app.py
View file

@ -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():

2
db.py
View file

@ -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 = [

View file

@ -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 "$@"