@@ -17,20 +17,21 @@ Code Glue is a Home Assistant addon that allows users to write automations and c
1717
1818### Runtime Structure in Container
1919```
20- /app/
21- ├── server/
22- │ ├── dist/
23- │ │ └── client/ # Static web files served here
24- │ ├── app/
25- │ │ └── environments/
26- │ │ └── prebuilt/ # Production entry point
27- │ ├── migrations/ # Database migration files
28- │ │ ├── sqlite/
29- │ │ ├── mysql/
30- │ │ └── postgresql/
31- │ └── drizzle.config.ts
20+ /work/ # Working directory
21+ ├── dist/
22+ │ ├── server/ # Compiled server code
23+ │ └── client/ # Static web files
24+ ├── apps/
25+ │ └── server/
26+ │ └── migrations/ # Database migration files
27+ │ ├── sqlite/
28+ │ ├── mysql/
29+ │ └── postgresql/
3230├── node_modules/
3331└── [other files]
32+
33+ /data/ # Persistent volume (Home Assistant provided)
34+ └── synapse_storage.db # SQLite database (persists across restarts)
3435```
3536
3637## Key Technologies
@@ -78,23 +79,23 @@ The server has multiple entry points in `dist/server/app/environments/`:
7879### Prebuilt Environment
7980- Entry: ` dist/server/app/environments/prebuilt/main.mjs `
8081- Sets ` SERVE_STATIC=true ` and ` ATTACH_STANDARD_MIDDLEWARE=true `
81- - Expects client at ` process.cwd() + '/server/ dist/client' ` → ` /app/server /dist/client/ `
82+ - Expects client at ` process.cwd() + '/dist/client' ` → ` /work /dist/client/ `
8283- Runs on port 3789 (configurable via PORT env var)
8384
8485## Static File Serving
8586
8687The server's ` StaticFileService ` (` apps/server/src/http/services/static.service.mts ` ):
8788- Looks for client at ` path.resolve(process.cwd(), "dist/client") `
88- - With workdir ` /app ` , this resolves to ` /app /dist/client `
89- - ** Current setup** : Client copied to ` /app/server /dist/client/ ` in Dockerfile
89+ - With workdir ` /work ` , this resolves to ` /work /dist/client `
90+ - ** Current setup** : Client copied to ` /work /dist/client/ ` in Dockerfile
9091- Serves SPA with catch-all routing (all non-API routes → ` index.html ` )
9192
9293## Container Startup Flow
9394
94951 . ** Entrypoint script** (` scripts/docker-entrypoint.sh ` ):
95- - Runs database migrations: ` cd /app /server && npx drizzle-kit migrate `
96- - Sets ` DATABASE_URL=file:/app /synapse_storage.db `
97- - Starts server: ` tsx /app /server/app/environments/prebuilt/main.mjs`
96+ - Runs database migrations: ` cd /work/apps /server && npx drizzle-kit migrate `
97+ - Sets ` DATABASE_URL=file:/data /synapse_storage.db `
98+ - Starts server: ` node dist /server/app/environments/prebuilt/main.mjs`
9899
991002 . ** Server bootstrap** :
100101 - Initializes Digital Alchemy services
@@ -123,7 +124,7 @@ The server's `StaticFileService` (`apps/server/src/http/services/static.service.
123124
124125### 404 Errors on Web UI
125126- ** Cause** : Static files not at expected path
126- - ** Fix** : Ensure client copied to ` /app/server /dist/client/ ` in Dockerfile to match ` StaticFileService ` expectations
127+ - ** Fix** : Ensure client copied to ` /work /dist/client/ ` in Dockerfile to match ` StaticFileService ` expectations
127128
128129### "Can't find meta/_ journal.json" Error
129130- ** Cause** : ` DatabaseInternalsService ` tries to run migrations but looks in wrong location
@@ -178,11 +179,11 @@ The repo includes `.devcontainer/devcontainer.json` using `ghcr.io/home-assistan
178179
179180| Description | Path in Container | Source in Build |
180181| -------------| ------------------| -----------------|
181- | Server code | ` /app /server/ ` | ` dist/server/ ` |
182- | Client static files | ` /app/server /dist/client/ ` | ` apps/client/dist/ ` |
183- | Migrations | ` /app /server/migrations/ ` | ` apps/server/migrations/ ` |
184- | Database | ` /app /synapse_storage.db ` | Created at runtime |
185- | Node modules | ` /app /node_modules/ ` | Copied from build stage |
182+ | Server code | ` /work/dist /server/ ` | ` dist/server/ ` |
183+ | Client static files | ` /work /dist/client/ ` | ` apps/client/dist/ ` |
184+ | Migrations | ` /work/apps /server/migrations/ ` | ` apps/server/migrations/ ` |
185+ | Database | ` /data /synapse_storage.db ` | Created at runtime (persistent volume) |
186+ | Node modules | ` /work /node_modules/ ` | Copied from build stage |
186187| Entrypoint | ` /docker-entrypoint.sh ` | ` scripts/docker-entrypoint.sh ` |
187188
188189## Testing Checklist
0 commit comments