docker-compose.dev.yml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Dev overlay — load alongside docker-compose.yml:
  2. # docker compose -f docker-compose.yml -f docker-compose.dev.yml up
  3. # (or `make dev`).
  4. #
  5. # Differences from prod:
  6. # * APP_ENV=development → Twig auto_reload kicks in (see View.php:36)
  7. # * Source dirs bind-mounted from host so edits show up without rebuild
  8. # * css-watcher sidecar runs `tailwindcss --watch` and seeds vendor JS
  9. # * tests profile builds the `tests` Dockerfile target on demand
  10. #
  11. # Volumes intentionally mount specific subdirs, NOT the project root —
  12. # mounting `.` would mask the composer-installed /var/www/html/vendor.
  13. services:
  14. app:
  15. environment:
  16. APP_ENV: development
  17. volumes:
  18. - ./src:/var/www/html/src
  19. - ./views:/var/www/html/views
  20. - ./public:/var/www/html/public
  21. - ./assets:/var/www/html/assets
  22. - ./migrations:/var/www/html/migrations
  23. - ./bin:/var/www/html/bin
  24. - ./tailwind.config.js:/var/www/html/tailwind.config.js
  25. - ./composer.json:/var/www/html/composer.json
  26. - ./composer.lock:/var/www/html/composer.lock
  27. - ./phpunit.xml:/var/www/html/phpunit.xml
  28. css-watcher:
  29. build:
  30. context: .
  31. target: css-watcher
  32. # Run as the host user so files written into the bind-mounted host dirs
  33. # (public/assets/css/app.css, public/assets/js/vendor/*) land with the
  34. # right ownership and don't need a `sudo chown` later. The Makefile
  35. # exports HOST_UID/HOST_GID; the :-1000 fallback covers the typical
  36. # case when someone invokes compose directly without going through make.
  37. user: "${HOST_UID:-1000}:${HOST_GID:-1000}"
  38. volumes:
  39. - ./assets:/build/assets
  40. - ./views:/build/views
  41. - ./src:/build/src
  42. - ./public:/build/public
  43. - ./tailwind.config.js:/build/tailwind.config.js
  44. restart: unless-stopped
  45. tests:
  46. build:
  47. context: .
  48. target: tests
  49. profiles: ["test"]
  50. env_file: .env
  51. # Read-only bind mounts — tests should never mutate source. The data
  52. # volume is anonymous and per-run, so each `docker compose run --rm
  53. # tests` gets a fresh SQLite via the entrypoint's migrate step.
  54. volumes:
  55. - ./src:/var/www/html/src:ro
  56. - ./tests:/var/www/html/tests:ro
  57. - ./views:/var/www/html/views:ro
  58. - ./migrations:/var/www/html/migrations:ro
  59. - ./bin:/var/www/html/bin:ro
  60. - ./phpunit.xml:/var/www/html/phpunit.xml:ro
  61. - ./composer.json:/var/www/html/composer.json:ro
  62. - ./composer.lock:/var/www/html/composer.lock:ro