Containerised dev deployment (hot-reload, restart-on-boot) - #1
Open
lightspeed-internal-1[bot] wants to merge 1 commit into
Open
lightspeed-internal-1[bot] wants to merge 1 commit into
lightspeed-internal-1[bot] wants to merge 1 commit into
Conversation
Runs Imaginator in Docker with the source bind-mounted, so the server hot-reloads on edit instead of needing an image rebuild. Aimed at long-lived dev/demo boxes where the app should come back by itself after a reboot. - Dockerfile.dev: node:22 + pnpm, source not baked in - docker-compose.yml: restart=always, port 8080, node_modules in named volumes (better-sqlite3 and sharp are native and must match the container, not the host), healthcheck on /api/health - docker-entrypoint.sh: install deps and build web when missing, then run the server under tsx watch - ctl.sh: status/logs/web/restart/up/down/shell/reinstall The data dir stays a host bind-mount, so the SQLite DB and generated assets live outside the container layer and survive rebuilds. Server and core edits reload in ~4s; web edits need ./ctl.sh web.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional Docker setup for running Imaginator on a long-lived dev/demo box, where two things matter: the app should come back after a reboot, and it should be editable in place.
Approach
Source is bind-mounted rather than baked into the image, and the server runs under
tsx watch. Editingpackages/serverorpackages/corereloads in ~4s with no rebuild;packages/webedits need./ctl.sh web(~3s), since the server already servespackages/web/distwhenever it exists — so the UI stays on the same single port.Files
Dockerfile.dev— node:22-bookworm-slim, build tools for the native deps, pnpm 10.15.1docker-compose.yml—restart: always, publishes 8080,env_file: .env, healthcheck on/api/healthdocker-entrypoint.sh— installs deps and builds web when missing, then starts the server in watch modectl.sh—status|logs|web|restart|up|down|shell|reinstall.gitignore— ignore.pnpm-store/Notes
node_moduleslive in named volumes, not on the host.better-sqlite3andsharpare native and must be built against the container rather than the host's Node../ctl.sh reinstallwipes those volumes and reinstalls.down/up. Verified by migrating a running instance from bare-metal into the container with assets intact.ctl.shtakes the public URL fromIMAGINATOR_PUBLIC_URLand otherwise checks localhost only, so nothing environment-specific is committed..gitignoreline.run.shis untouched and still the right tool for local work.Caveat
restart: alwaysrestores the container on daemon start, which covers reboots given an enableddocker.service. This has not been verified against a real VM stop/start yet. Note also thatdocker kill/docker stopare treated as manual stops and deliberately do not trigger the restart policy, so they are not valid tests of it.