Add --data-dir CLI argument to replace symlink-based data persistence
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:
Jan Novak
2026-02-15 22:56:41 +01:00
parent a1212c6312
commit a09876d749
12 changed files with 88 additions and 48 deletions

View File

@@ -5,6 +5,7 @@ Doplní chybějící plochy ze Sreality API, opraví URL, aplikuje filtry.
"""
from __future__ import annotations
import argparse
import json
import time
import urllib.request
@@ -57,8 +58,9 @@ def fetch_area(hash_id: int) -> int | None:
return None
def main():
json_path = Path("byty_sreality.json")
def main(data_dir: str = "."):
data_path = Path(data_dir)
json_path = data_path / "byty_sreality.json"
if not json_path.exists():
print("Soubor byty_sreality.json nenalezen. Nejprve spusť scrape_and_map.py")
return
@@ -100,15 +102,19 @@ def main():
print(f"Zbývá: {len(filtered)} bytů")
# Save updated data
filtered_path = Path("byty_sreality.json")
filtered_path = data_path / "byty_sreality.json"
filtered_path.write_text(
json.dumps(filtered, ensure_ascii=False, indent=2),
encoding="utf-8",
)
# Generate map
generate_map(filtered)
generate_map(filtered, output_path=str(data_path / "mapa_bytu.html"))
if __name__ == "__main__":
main()
parser = argparse.ArgumentParser(description="Regenerate map from existing data")
parser.add_argument("--data-dir", type=str, default=".",
help="Directory for reading/writing data files (default: current dir)")
args = parser.parse_args()
main(data_dir=args.data_dir)