Skip to content

feat(dev): docker compose watch — live-reload for api and web - #9

Merged
avetisk merged 1 commit into
mainfrom
chore/compose-watch
Jul 9, 2026
Merged

feat(dev): docker compose watch — live-reload for api and web#9
avetisk merged 1 commit into
mainfrom
chore/compose-watch

Conversation

@avetisk

@avetisk avetisk commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Adds a first-class docker compose watch dev loop that live-reloads both services on edits.

Why

The stack bind-mounted src and relied on the in-container watchers (vite HMR / tsx watch) seeing changes through the mount. That works on native Linux but not on macOS/Windows, where bind-mount inotify events don't propagate — so "watch doesn't reload." It also can't react to dependency changes (adding a dep needs a manual --build).

What

develop.watch on both services:

  • sync api/web/shared source into the running container. Sync writes into the container's own filesystem (via the Docker API), not through a bind mount, so the in-container watcher fires on every platform.
  • rebuild the image when that service's package.json or pnpm-lock.yaml changes.
  • sync+restart web on a vite.config.ts / tsr.config.json change (vite reads them only at startup). The router's generated tree + temp dir (gitignored) are excluded from the sync so the container owns its codegen.

The src bind mounts are removed (sync replaces them, and keeping them would defeat the cross-platform fix). Plain docker compose up still runs the stack as built (no watching) — what the CI smoke job uses.

Verified locally

  • docker compose watch: editing a web file reloads via HMR (~1s); editing an api file triggers [tsx] change … Restarting… (~1s). Log shows Syncing service "web" / "api".
  • docker compose up (smoke-job path) still passes without the bind mount: API health OK, web shell has #root, and routeTree.gen.ts is generated in the container (vite's router plugin runs on startup regardless of the mount).
  • docker compose config validates; lint/fmt green.

README's "Getting started" updated to lead with docker compose watch.

Note: independent of PR #8 (Slice 2d). Both touch docker-compose.yml in non-overlapping regions (this one the volumes/develop blocks + header; #8 the api PUBLIC_BASE_URL env line), so they merge cleanly in either order.

🤖 Generated with Claude Code

Adds a first-class watch mode to the dev stack. `docker compose watch` starts the
stack and live-reloads on edits:

- `sync` api/web/shared source into the running container, where the in-container
  watcher reloads (vite HMR for web, `tsx watch` restart for api). Sync writes into
  the container's own filesystem rather than through a bind mount, so it also works
  on macOS/Windows, where bind-mount inotify events don't propagate — the reason a
  plain bind-mount setup "doesn't reload" there.
- `rebuild` the image when a service's package.json or the lockfile changes (adding a
  dependency no longer needs a manual --build).
- `sync+restart` web on a vite.config.ts / tsr.config.json change (vite reads them
  only at startup). The router's generated tree + temp dir (gitignored) are excluded
  from the sync so the container owns its own codegen.

The src bind mounts are removed (sync replaces them). Plain `docker compose up` still
runs the stack as built (no watching) — what the CI smoke job uses; verified it still
serves and generates routeTree.gen.ts in-container without the mount. README updated.

Verified: `docker compose watch` reloads web (~1s) and api (tsx restart) on edits.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@avetisk

avetisk commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

LGTM.

@avetisk
avetisk merged commit efaca51 into main Jul 9, 2026
2 checks passed
@avetisk
avetisk deleted the chore/compose-watch branch July 9, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant