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>
164 lines
4.9 KiB
YAML
164 lines
4.9 KiB
YAML
# Development containers, these should only be used if you are developing.
|
|
version: '3'
|
|
services:
|
|
db: # https://github.com/docker-library/docs/tree/master/postgres
|
|
image: postgres:12
|
|
environment:
|
|
- POSTGRES_DB=wrolpi
|
|
- POSTGRES_PASSWORD=wrolpi
|
|
ports:
|
|
- "5432:5432"
|
|
healthcheck:
|
|
test: [ 'CMD-SHELL', 'pg_isready -U postgres' ]
|
|
interval: 10s
|
|
start_period: 30s
|
|
start_interval: 1s
|
|
volumes:
|
|
- ./pg_data:/var/lib/postgresql/data
|
|
|
|
controller: # WROLPi Controller Service
|
|
build:
|
|
context: .
|
|
dockerfile: docker/controller/Dockerfile
|
|
restart: unless-stopped
|
|
ports:
|
|
- "8080:80"
|
|
volumes:
|
|
# Controller code (for development hot-reload)
|
|
- ./controller:/app/controller
|
|
# Docker socket for container management
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
# Host system info (read-only)
|
|
- /proc:/host/proc:ro
|
|
- /sys:/host/sys:ro
|
|
# Media directory (needed for Samba share path validation)
|
|
- ${MEDIA_DIRECTORY:-./test}:/media/wrolpi
|
|
environment:
|
|
- DOCKERIZED=true
|
|
- MEDIA_DIRECTORY=/media/wrolpi
|
|
# Override CMD to enable auto-reload for development
|
|
command: ["python", "-m", "controller.serve"]
|
|
healthcheck:
|
|
test: [ 'CMD-SHELL', 'curl -f http://127.0.0.1:80/api/health || exit 1' ]
|
|
interval: 30s
|
|
timeout: 5s
|
|
start_period: 10s
|
|
retries: 3
|
|
|
|
api:
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
controller:
|
|
condition: service_started
|
|
build:
|
|
context: .
|
|
dockerfile: docker/api/Dockerfile
|
|
environment:
|
|
# Sanic 25.x wants 'spawn' but our code uses 'fork' for multiprocessing.
|
|
# This tells Sanic to accept the existing start method.
|
|
- SANIC_START_METHOD_SET=1
|
|
volumes:
|
|
- './main.py:/opt/wrolpi/main.py'
|
|
- './wrolpi:/opt/wrolpi/wrolpi'
|
|
- './modules:/opt/wrolpi/modules'
|
|
- './scripts:/opt/wrolpi/scripts'
|
|
- './test:/opt/wrolpi/test'
|
|
- './test:/media/wrolpi'
|
|
- './alembic:/opt/wrolpi/alembic'
|
|
- './alembic.ini:/opt/wrolpi/alembic.ini'
|
|
ports:
|
|
- ${REACT_APP_API-0.0.0.0:8081}:8081
|
|
user: '${UID-1000}:${GID-1000}'
|
|
healthcheck:
|
|
test: [ 'CMD-SHELL', 'curl http://127.0.0.1:8081/api/echo' ]
|
|
interval: 2m
|
|
|
|
archive: # Python/Sanic wrapper around Singlefile and Readability.
|
|
build:
|
|
context: .
|
|
dockerfile: docker/archive/Dockerfile
|
|
volumes:
|
|
- './docker/archive/main.py:/app/main.py'
|
|
ports:
|
|
- '8083:8080'
|
|
healthcheck:
|
|
test: [ 'CMD-SHELL', 'curl http://127.0.0.1:8080/' ]
|
|
interval: 2m
|
|
|
|
app: # React App
|
|
depends_on:
|
|
- api
|
|
build:
|
|
context: .
|
|
dockerfile: docker/app/Dockerfile
|
|
# The image builds the production bundle and serves it (see docker/app/Dockerfile), so the PWA service worker
|
|
# ships. Rebuild the image (`docker compose build app`) to pick up code changes. For local development with
|
|
# hot reload, layer on docker-compose.dev.yml (runs the CRA dev server instead).
|
|
healthcheck:
|
|
test: [ 'CMD-SHELL', 'curl http://127.0.0.1:3000' ]
|
|
interval: 1m
|
|
user: '${UID-1000}:${GID-1000}'
|
|
|
|
web: # Caddy reverse proxy - handles HTTPS for all services.
|
|
depends_on:
|
|
- app
|
|
- zim
|
|
- help
|
|
build:
|
|
context: .
|
|
dockerfile: docker/web/Dockerfile
|
|
ports:
|
|
- ${WEB_HOST-0.0.0.0}:${WEB_HTTPS_PORT-8443}:443
|
|
- '8084:8084'
|
|
- '8085:8085'
|
|
- '8086:8086'
|
|
volumes:
|
|
- './docker/web/Caddyfile:/etc/caddy/Caddyfile'
|
|
- './icon.ico:/etc/caddy/favicon.ico'
|
|
- './icon.png:/etc/caddy/icon.png'
|
|
- './test:/opt/media'
|
|
- './modules/map/static:/opt/wrolpi/modules/map/static:ro'
|
|
- './blobs:/opt/wrolpi-blobs:ro'
|
|
environment:
|
|
- MEDIA_DIRECTORY=/opt/media
|
|
# Set EXTRA_SANS to include the host's LAN IP in the TLS certificate.
|
|
# Example: EXTRA_SANS=IP:10.0.0.5
|
|
- EXTRA_SANS=${EXTRA_SANS:-}
|
|
healthcheck:
|
|
test: [ 'CMD-SHELL', 'wget --spider --no-check-certificate https://127.0.0.1:443 || exit 1' ]
|
|
interval: 1m
|
|
|
|
zim: # kiwix-serve
|
|
build:
|
|
context: .
|
|
dockerfile: docker/zim/Dockerfile
|
|
volumes:
|
|
- './test:/media/wrolpi'
|
|
- './docker/zim/entrypoint.sh:/entrypoint.sh'
|
|
healthcheck:
|
|
test: [ 'CMD-SHELL', 'curl http://127.0.0.1:80' ]
|
|
interval: 1m
|
|
|
|
samba: # Samba file sharing - started/stopped by the controller based on configured shares.
|
|
build:
|
|
context: .
|
|
dockerfile: docker/samba/Dockerfile
|
|
restart: "no"
|
|
depends_on:
|
|
controller:
|
|
condition: service_healthy
|
|
ports:
|
|
- "445:445"
|
|
volumes:
|
|
- ${MEDIA_DIRECTORY:-./test}:/media/wrolpi
|
|
|
|
help: # The WROLPi Help documentation.
|
|
build:
|
|
context: .
|
|
dockerfile: docker/help/Dockerfile
|
|
volumes:
|
|
- './docker/help/wrolpi-help:/opt/wrolpi-help'
|
|
healthcheck:
|
|
test: [ 'CMD-SHELL', 'curl http://127.0.0.1:8086' ]
|
|
interval: 1m
|