mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 09:26:17 -05:00
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>
25 lines
819 B
Docker
25 lines
819 B
Docker
# base image
|
|
FROM node:18-bullseye
|
|
|
|
WORKDIR /app
|
|
ENV PATH /app/node_modules/.bin:$PATH
|
|
|
|
# install and cache app dependencies
|
|
USER root
|
|
RUN npm install -g serve
|
|
COPY app/public /app/public
|
|
COPY app/src /app/src
|
|
COPY app/package.json app/package-lock.json app/tsconfig.json app/serve.json /app/
|
|
# "node" user will run the app after build.
|
|
RUN chown -R node:node /app
|
|
|
|
# Install dependencies as "node", this is to avoid changing ownership of many files.
|
|
USER node
|
|
RUN npm install
|
|
|
|
# Build the production bundle (emits the PWA service worker; the dev server does not).
|
|
RUN npm run build
|
|
|
|
# Serve the production build, matching the native wrolpi-app.service. serve.json keeps the SPA fallback while
|
|
# serving real files (service-worker.js, epub.html) directly.
|
|
CMD ["serve", "build", "-l", "3000", "-c", "/app/serve.json"]
|