Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Convenience wrappers for the dev/prod compose split. Targets are split
  2. # along the same axis as the compose files: anything `dev-*` uses the
  3. # overlay, anything else hits prod.
  4. COMPOSE_PROD = docker compose
  5. COMPOSE_DEV = docker compose -f docker-compose.yml -f docker-compose.dev.yml
  6. # Exported so the css-watcher service can run as the host user via
  7. # `user: "${HOST_UID}:${HOST_GID}"` in docker-compose.dev.yml. Files the
  8. # watcher writes into bind-mounted host paths (public/assets/css/app.css,
  9. # public/assets/js/vendor/*) then land with normal ownership.
  10. export HOST_UID := $(shell id -u)
  11. export HOST_GID := $(shell id -g)
  12. .PHONY: help dev dev-build dev-down prod prod-build prod-down \
  13. test lint check shell logs
  14. help:
  15. @echo "Dev:"
  16. @echo " make dev start dev stack (app + css-watcher) in foreground"
  17. @echo " make dev-build rebuild dev images"
  18. @echo " make dev-down stop and remove dev containers"
  19. @echo " make shell bash into the running app container"
  20. @echo " make logs tail logs from the dev stack"
  21. @echo ""
  22. @echo "Prod:"
  23. @echo " make prod start prod stack detached"
  24. @echo " make prod-build rebuild prod image"
  25. @echo " make prod-down stop and remove prod containers"
  26. @echo ""
  27. @echo "Checks (one-shot containers, no running stack required):"
  28. @echo " make lint php -l on src/ + tests/"
  29. @echo " make test phpunit"
  30. @echo " make check lint + test (used by /check skill)"
  31. # --- dev ----------------------------------------------------------------
  32. dev:
  33. $(COMPOSE_DEV) up
  34. dev-build:
  35. $(COMPOSE_DEV) build
  36. dev-down:
  37. $(COMPOSE_DEV) down
  38. shell:
  39. $(COMPOSE_DEV) exec app bash
  40. logs:
  41. $(COMPOSE_DEV) logs -f
  42. # --- prod ---------------------------------------------------------------
  43. prod:
  44. $(COMPOSE_PROD) up -d
  45. prod-build:
  46. $(COMPOSE_PROD) build
  47. prod-down:
  48. $(COMPOSE_PROD) down
  49. # --- checks (one-shot, profile=test) ------------------------------------
  50. # `run --rm` builds the tests image if needed, runs the command, and
  51. # tears the container down. Doesn't require `make dev` to be running.
  52. lint:
  53. $(COMPOSE_DEV) --profile test run --rm tests \
  54. sh -c 'find src tests -name "*.php" -print0 | xargs -0 -n1 -P 4 php -l > /dev/null && echo "lint: OK"'
  55. test:
  56. $(COMPOSE_DEV) --profile test run --rm tests
  57. check: lint test