added entrypoint for Reticulum in Docker
Replaces static CMD with an entrypoint that generates RNS config from environment variables (RNS_TCP_HOST/PORT), enabling TCP transport for environments without LAN auto-discovery (e.g. Docker on macOS).
This commit is contained in:
parent
e802ed4fe3
commit
14aafad337
4 changed files with 49 additions and 2 deletions
|
|
@ -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"]
|
||||
|
|
|
|||
2
app.py
2
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(
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
39
entrypoint.sh
Executable file
39
entrypoint.sh
Executable file
|
|
@ -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" <<EOF
|
||||
[reticulum]
|
||||
enable_transport = False
|
||||
share_instance = Yes
|
||||
|
||||
[logging]
|
||||
loglevel = 4
|
||||
|
||||
[interfaces]
|
||||
[[Default Interface]]
|
||||
type = AutoInterface
|
||||
enabled = Yes
|
||||
EOF
|
||||
|
||||
if [ -n "$RNS_TCP_HOST" ]; then
|
||||
RNS_TCP_PORT="${RNS_TCP_PORT:-4242}"
|
||||
cat >> "$CONFIG_FILE" <<EOF
|
||||
|
||||
[[TCP Link]]
|
||||
type = TCPClientInterface
|
||||
enabled = yes
|
||||
target_host = $RNS_TCP_HOST
|
||||
target_port = $RNS_TCP_PORT
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
export RNS_CONFIG_DIR="$CONFIG_DIR"
|
||||
exec python app.py
|
||||
Loading…
Add table
Add a link
Reference in a new issue