Add --data-dir CLI argument to replace symlink-based data persistence
All checks were successful
Build and Push / build (push) Successful in 7s
All checks were successful
Build and Push / build (push) Successful in 7s
The Docker entrypoint previously created symlinks from /app/ to /app/data/ so that scripts writing relative paths would persist to the mounted volume. This caused symlink loops in production when stale symlinks leaked into the host data directory. Instead, all scrapers, merge_and_map.py, regen_map.py, and run_all.sh now accept a --data-dir argument (default: ".") that controls where data files are read from and written to. The entrypoint and crontab pass --data-dir /app/data, eliminating the need for symlinks entirely. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
0 6,18 * * * cd /app && bash /app/run_all.sh >> /proc/1/fd/1 2>> /proc/1/fd/2
|
||||
0 6,18 * * * cd /app && bash /app/run_all.sh --data-dir /app/data >> /proc/1/fd/1 2>> /proc/1/fd/2
|
||||
|
||||
@@ -3,20 +3,11 @@ set -euo pipefail
|
||||
|
||||
DATA_DIR="/app/data"
|
||||
|
||||
# Create symlinks so scripts (which write to /app/) persist data to the volume
|
||||
for f in byty_sreality.json byty_realingo.json byty_bezrealitky.json \
|
||||
byty_idnes.json byty_psn.json byty_cityhome.json byty_merged.json \
|
||||
mapa_bytu.html; do
|
||||
# Remove real file if it exists (e.g. baked into image)
|
||||
[ -f "/app/$f" ] && [ ! -L "/app/$f" ] && rm -f "/app/$f"
|
||||
ln -sf "$DATA_DIR/$f" "/app/$f"
|
||||
done
|
||||
|
||||
echo "[entrypoint] Starting crond..."
|
||||
crond -b -l 2
|
||||
|
||||
echo "[entrypoint] Starting initial scrape in background..."
|
||||
bash /app/run_all.sh &
|
||||
bash /app/run_all.sh --data-dir "$DATA_DIR" &
|
||||
|
||||
echo "[entrypoint] Starting HTTP server on port 8080..."
|
||||
exec python3 -m http.server 8080 --directory "$DATA_DIR"
|
||||
|
||||
9
build/run.sh
Normal file
9
build/run.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker rm -f maru-hleda-byt
|
||||
|
||||
# gitea registry login with kacerr / token
|
||||
docker run -d --name maru-hleda-byt \
|
||||
-p 8080:8080 \
|
||||
-v /srv/maru-hleda-byt/data:/app/data \
|
||||
gitea.home.hrajfrisbee.cz/littlemeat/maru-hleda-byt:0.01
|
||||
Reference in New Issue
Block a user