diff --git a/Dockerfile b/Dockerfile index 76fcb4e..9895f65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,8 @@ RUN mkdir -p /data \ && ln -sf /data/index.db index.db \ && ln -sf /data/tinyweb_identity tinyweb_identity +ENV PYTHONUNBUFFERED=1 + EXPOSE 8080 -CMD ["python", "app.py"] +ENTRYPOINT ["./entrypoint.sh"] diff --git a/app.py b/app.py index 01c4541..2149429 100644 --- a/app.py +++ b/app.py @@ -42,7 +42,7 @@ def start_gateway(reticulum): def main(): init_db() - reticulum = RNS.Reticulum() + reticulum = RNS.Reticulum(configdir=os.environ.get("RNS_CONFIG_DIR")) identity = load_or_create_identity() destination = RNS.Destination( diff --git a/docker-compose.yml b/docker-compose.yml index 99191f2..151a79c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,12 @@ services: volumes: - tinyweb-data:/data restart: unless-stopped + # Connect to another Reticulum instance over TCP. + # Required on macOS (Docker can't do LAN auto-discovery). + # On Linux, auto-discovery works with network_mode: host. + # environment: + # - RNS_TCP_HOST=10.0.0.100 + # - RNS_TCP_PORT=4242 volumes: tinyweb-data: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..4131973 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Generate Reticulum config with optional TCP peer +# Set RNS_TCP_HOST and RNS_TCP_PORT env vars to connect to a remote instance + +CONFIG_DIR="/data/.reticulum" +CONFIG_FILE="$CONFIG_DIR/config" + +mkdir -p "$CONFIG_DIR" + +if [ ! -f "$CONFIG_FILE" ]; then + cat > "$CONFIG_FILE" <> "$CONFIG_FILE" <