All checks were successful
Build and Push / build (push) Successful in 7s
Key changes:
- Replace ratings_server.py + status.html with a unified server.py that
serves the map, scraper status dashboard, and ratings API in one process
- Add scraper_stats.py utility: each scraper writes per-run stats (fetched,
accepted, excluded, duration) to stats_<source>.json for the status page
- generate_status.py: respect DATA_DIR env var so status.json lands in the
configured data directory instead of always the project root
- run_all.sh: replace the {"status":"running"} overwrite of status.json with
a dedicated scraper_running.json lock file; trap on EXIT ensures cleanup
even on kill/error, preventing the previous run's results from being wiped
- server.py: detect running state via scraper_running.json existence instead
of status["status"] field, eliminating the dual-use race condition
- Makefile: add serve (local dev), debug (Docker debug container) targets;
add SERVER_PORT variable
- build/Dockerfile + entrypoint.sh: switch to server.py, set DATA_DIR,
adjust volume mounts
- .gitignore: add *.json and *.log to keep runtime data files out of VCS
- mapa_bytu.html: price-per-m² colouring, status link, UX tweaks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
100 lines
3.7 KiB
Makefile
100 lines
3.7 KiB
Makefile
IMAGE_NAME := maru-hleda-byt
|
|
CONTAINER_NAME := maru-hleda-byt
|
|
VOLUME_NAME := maru-hleda-byt-data
|
|
VALIDATION_CONTAINER := maru-hleda-byt-validation
|
|
VALIDATION_VOLUME := maru-hleda-byt-validation-data
|
|
DEBUG_CONTAINER := maru-hleda-byt-debug
|
|
DEBUG_VOLUME := maru-hleda-byt-debug-data
|
|
DEBUG_PORT ?= 8082
|
|
PORT := 8080
|
|
SERVER_PORT ?= 8080
|
|
|
|
.PHONY: build run stop logs scrape restart clean help serve validation validation-local validation-stop validation-local-debug debug debug-stop
|
|
|
|
help:
|
|
@echo "Available targets:"
|
|
@echo " build - Build the Docker image"
|
|
@echo " run - Build and run the Docker container in the background"
|
|
@echo " stop - Stop and remove the running container"
|
|
@echo " logs - Show live container logs"
|
|
@echo " scrape - Run the scraping script inside the container"
|
|
@echo " validation - Run scraping with limits (1 page, 10 properties) in Docker container"
|
|
@echo " validation-stop - Stop the validation Docker container"
|
|
@echo " validation-local - Run scraping with limits (1 page, 10 properties) locally with Python"
|
|
@echo " validation-local-debug - Run validation locally with DEBUG logging"
|
|
@echo " restart - Restart the container (stop and run again)"
|
|
@echo " clean - Stop container and remove the Docker image"
|
|
@echo " serve - Start server.py locally on port 8080"
|
|
@echo " debug - Build and run debug Docker container with limited scrape (port $(DEBUG_PORT))"
|
|
@echo " debug-stop - Stop and remove the debug Docker container"
|
|
@echo " help - Show this help message"
|
|
|
|
build:
|
|
docker build -f build/Dockerfile -t $(IMAGE_NAME) .
|
|
|
|
run: build
|
|
docker run -d --name $(CONTAINER_NAME) \
|
|
-p $(PORT):8080 \
|
|
-v $(VOLUME_NAME):/app/data \
|
|
--restart unless-stopped \
|
|
$(IMAGE_NAME)
|
|
@echo "Map will be at http://localhost:$(PORT)/mapa_bytu.html"
|
|
|
|
stop:
|
|
docker stop $(CONTAINER_NAME) && docker rm $(CONTAINER_NAME)
|
|
|
|
logs:
|
|
docker logs -f $(CONTAINER_NAME)
|
|
|
|
scrape:
|
|
docker exec $(CONTAINER_NAME) bash /app/run_all.sh
|
|
|
|
validation: build
|
|
@docker stop $(VALIDATION_CONTAINER) 2>/dev/null || true
|
|
@docker rm $(VALIDATION_CONTAINER) 2>/dev/null || true
|
|
docker run -d --name $(VALIDATION_CONTAINER) \
|
|
-p 8081:8080 \
|
|
-v $(VALIDATION_VOLUME):/app/data \
|
|
--restart unless-stopped \
|
|
$(IMAGE_NAME)
|
|
@sleep 2
|
|
docker exec $(VALIDATION_CONTAINER) bash /app/run_all.sh --max-pages 1 --max-properties 10
|
|
@echo "Validation map will be at http://localhost:8081/mapa_bytu.html"
|
|
|
|
validation-stop:
|
|
@docker stop $(VALIDATION_CONTAINER) 2>/dev/null || true
|
|
@docker rm $(VALIDATION_CONTAINER) 2>/dev/null || true
|
|
@echo "Validation container stopped and removed"
|
|
|
|
debug: build
|
|
@docker stop $(DEBUG_CONTAINER) 2>/dev/null || true
|
|
@docker rm $(DEBUG_CONTAINER) 2>/dev/null || true
|
|
docker run -d --name $(DEBUG_CONTAINER) \
|
|
-p $(DEBUG_PORT):8080 \
|
|
-v $(DEBUG_VOLUME):/app/data \
|
|
-e LOG_LEVEL=DEBUG \
|
|
$(IMAGE_NAME)
|
|
@sleep 2
|
|
docker exec $(DEBUG_CONTAINER) bash /app/run_all.sh --max-pages 1 --max-properties 10
|
|
@echo "Debug app at http://localhost:$(DEBUG_PORT)/mapa_bytu.html"
|
|
@echo "Debug status at http://localhost:$(DEBUG_PORT)/scrapers-status"
|
|
|
|
debug-stop:
|
|
@docker stop $(DEBUG_CONTAINER) 2>/dev/null || true
|
|
@docker rm $(DEBUG_CONTAINER) 2>/dev/null || true
|
|
@echo "Debug container stopped and removed"
|
|
|
|
serve:
|
|
DATA_DIR=. SERVER_PORT=$(SERVER_PORT) python3 server.py
|
|
|
|
validation-local:
|
|
./run_all.sh --max-pages 1 --max-properties 10
|
|
|
|
validation-local-debug:
|
|
./run_all.sh --max-pages 1 --max-properties 10 --log-level DEBUG
|
|
|
|
restart: stop run
|
|
|
|
clean: stop
|
|
docker rmi $(IMAGE_NAME)
|