chore(docker): add development environment with hot reload

Add dev stage to Dockerfile and startup script
Create docker-compose.dev.yml for local development
Update README with Docker dev mode instructions
This commit is contained in:
2026-04-12 21:54:58 +08:00
parent 8541c4a2d1
commit 7f582b530c
4 changed files with 69 additions and 0 deletions

View File

@@ -65,6 +65,7 @@ The repo now includes a production-ready container stack:
- [Dockerfile](/mnt/d/SourceCode/tootaio/dinner-ticket-system/Dockerfile)
- [docker-compose.yml](/mnt/d/SourceCode/tootaio/dinner-ticket-system/docker-compose.yml)
- [docker-compose.dev.yml](/mnt/d/SourceCode/tootaio/dinner-ticket-system/docker-compose.dev.yml)
- [.dockerignore](/mnt/d/SourceCode/tootaio/dinner-ticket-system/.dockerignore)
Bring up the full environment:
@@ -97,6 +98,29 @@ docker compose down -v
For passkey testing in Docker, set `NUXT_PUBLIC_APP_URL` to the exact origin you open in the browser. In production, this should be your final HTTPS URL.
### Docker Development With Hot Reload
Use the dev override when you want live reload instead of rebuilding the image after every code change:
```bash
docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build
```
This keeps PostgreSQL and Redis in Docker, but runs the app container in Nuxt dev mode with:
- the project directory bind-mounted into `/app`
- a persistent `/app/node_modules` volume so dependencies stay inside Docker
- an automatic `pnpm install --frozen-lockfile` during app container startup
- polling-based file watching for reliable reloads on mounted filesystems
After the first start, code changes on the host should reload automatically without rebuilding the image.
When you change dependencies, restart the app container so it reruns `pnpm install` against the current lockfile:
```bash
docker compose -f docker-compose.yml -f docker-compose.dev.yml restart app
```
## Protected Areas
- `/login`