mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-30 03:46:29 -05:00
Serve the production build in Docker so the PWA service worker ships
The Docker app container ran the CRA dev server (`npm run start`), which never emits the Workbox service worker, so the PWA had no offline cache when deployed via Docker (native already serves the build via wrolpi-app.service). - docker/app/Dockerfile: build the bundle (`npm run build`) and serve it with `serve build -c /app/serve.json` (mirrors native; serve.json keeps the SPA fallback while serving service-worker.js and epub.html directly). - docker-compose.yml: drop the dev-server `command`/mounts so the base stack serves the production build (what end users run). - docker-compose.dev.yml: new opt-in override restoring the dev server + hot reload for local development: `docker compose -f docker-compose.yml -f docker-compose.dev.yml up` - docker/README.md: document the dev vs production run commands. Verified: served via Caddy, /service-worker.js now returns real JS (application/javascript) instead of the SPA index.html fallback; the SW registers, caches inventory, and serves it offline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
20d2bb8717
commit
f87921e2a7
4 changed files with 47 additions and 14 deletions
22
docker-compose.dev.yml
Normal file
22
docker-compose.dev.yml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Local development override for the React app.
|
||||
#
|
||||
# The base docker-compose.yml serves the production build (so the PWA service worker ships). This override runs
|
||||
# the Create React App dev server instead, restoring hot reload. The dev server does not emit a service worker —
|
||||
# that is expected; offline/PWA support is a production concern and is verified against a production build.
|
||||
#
|
||||
# Usage:
|
||||
# docker compose -f docker-compose.yml -f docker-compose.dev.yml up
|
||||
#
|
||||
# (Production / end users just run `docker compose up`, which serves the built PWA.)
|
||||
services:
|
||||
app:
|
||||
command: 'npm run start'
|
||||
stdin_open: true
|
||||
volumes:
|
||||
- './app/public:/app/public'
|
||||
- './app/src:/app/src'
|
||||
- './app/package.json:/app/package.json'
|
||||
- '.env:/app/.env'
|
||||
environment:
|
||||
# Force React to use the Caddy port for its dev-server websocket.
|
||||
- WDS_SOCKET_PORT=0
|
||||
Loading…
Add table
Add a link
Reference in a new issue