docker-compose.dev.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. # Tailwind's `--watch` mode listens on stdin and exits on EOF so a parent
  39. # process closing the pipe terminates it cleanly. Under `compose up` stdin
  40. # is closed by default, which makes the watcher exit 0 immediately and
  41. # `restart: unless-stopped` then loops it. Keeping stdin open + a TTY
  42. # attached lets chokidar actually start.
  43. stdin_open: true
  44. tty: true
  45. volumes:
  46. - ./assets:/build/assets
  47. - ./views:/build/views
  48. - ./src:/build/src
  49. - ./public:/build/public
  50. - ./tailwind.config.js:/build/tailwind.config.js
  51. restart: unless-stopped
  52. tests:
  53. build:
  54. context: .
  55. target: tests
  56. profiles: ["test"]
  57. env_file: .env
  58. # Read-only bind mounts — tests should never mutate source. The data
  59. # volume is anonymous and per-run, so each `docker compose run --rm
  60. # tests` gets a fresh SQLite via the entrypoint's migrate step.
  61. volumes:
  62. - ./src:/var/www/html/src:ro
  63. - ./tests:/var/www/html/tests:ro
  64. - ./views:/var/www/html/views:ro
  65. - ./migrations:/var/www/html/migrations:ro
  66. - ./bin:/var/www/html/bin:ro
  67. - ./phpunit.xml:/var/www/html/phpunit.xml:ro
  68. - ./composer.json:/var/www/html/composer.json:ro
  69. - ./composer.lock:/var/www/html/composer.lock:ro