# Project Variables ENV_FILE=.env ENV_EXAMPLE=.env.example DOCKER_COMPOSE=docker compose PROJECT_NAME=plant_price_tracker # Commands .PHONY: help up down rebuild logs status seed shell dbshell reset test help: @echo "Available targets:" @echo " up - Build and start the app (bootstraps .env if needed)" @echo " down - Stop and remove containers" @echo " rebuild - Rebuild containers from scratch" @echo " logs - Show logs for all services" @echo " status - Show container health status" @echo " seed - Manually seed the database" @echo " shell - Open a bash shell in the web container" @echo " dbshell - Open a MySQL shell" @echo " reset - Nuke everything and restart clean" @echo " test - Run test suite (TBD)" up: @if [ ! -f $(ENV_FILE) ]; then \ echo "[โš™] Generating .env from example..."; \ cp $(ENV_EXAMPLE) $(ENV_FILE); \ fi $(DOCKER_COMPOSE) up --build -d @$(MAKE) wait down: $(DOCKER_COMPOSE) down rebuild: $(DOCKER_COMPOSE) down -v --remove-orphans $(DOCKER_COMPOSE) up --build -d @$(MAKE) wait logs: $(DOCKER_COMPOSE) logs -f status: @echo "[๐Ÿ“Š] Health status of containers:" @docker ps --filter "name=$(PROJECT_NAME)-" --format "table {{.Names}}\t{{.Status}}" seed: @docker exec -it $$(docker ps -qf "name=$(PROJECT_NAME)-web") flask seed-admin shell: @docker exec -it $$(docker ps -qf "name=$(PROJECT_NAME)-web") bash dbshell: @docker exec -it $$(docker ps -qf "name=$(PROJECT_NAME)-db") \ mysql -u$$(grep MYSQL_USER $(ENV_FILE) | cut -d '=' -f2) \ -p$$(grep MYSQL_PASSWORD $(ENV_FILE) | cut -d '=' -f2) \ $$(grep MYSQL_DATABASE $(ENV_FILE) | cut -d '=' -f2) reset: @echo "[๐Ÿ’ฃ] Nuking containers and volumes..." $(DOCKER_COMPOSE) down -v --remove-orphans @echo "[๐Ÿงผ] Cleaning caches and migrations..." sudo rm -rf __pycache__ */__pycache__ */*/__pycache__ *.pyc *.pyo *.db migrations @echo "[๐Ÿš€] Rebuilding project fresh..." @$(MAKE) up test: @echo "[๐Ÿšง] Test suite placeholder" # insert pytest or unittest commands here wait: @echo "[โณ] Waiting for web container to be healthy..." @until [ "$$(docker inspect -f '{{.State.Health.Status}}' $(PROJECT_NAME)-web-1 2>/dev/null)" = "healthy" ]; do \ printf "."; sleep 2; \ done @echo "\n[โœ…] Web container is healthy!"