Files
rmyndharis--openwa/docker-entrypoint.sh
Yudhi Armyndharis 2732c5f73e fix(docker): align dashboard nginx host + clear stale Chromium singleton locks (#260)
* fix(docker): align dashboard nginx host and clear stale Chromium singleton locks

Two fixes salvaged from #259 (thanks @Abhishekrajpurohit):

- dashboard/nginx.conf proxied /api/ and /socket.io/ to a bare `openwa` host;
  the canonical backend service is `openwa-api` (production compose service name,
  dev container_name, and already used in Dockerfile.traefik). Point both blocks
  at openwa-api so the simple dashboard image works against the standard backend.

- docker-entrypoint.sh now removes stale Chromium SingletonLock/SingletonSocket/
  SingletonCookie files from session profiles on start. Chromium does not clean
  these up on an unclean shutdown, and the stale locks block the next launch
  ("profile appears to be in use", exit Code 21). No Chromium runs at entrypoint
  time, so clearing them is safe and lets sessions re-launch after a crash.

* chore: ignore .playwright-mcp/ artifacts
2026-06-16 23:07:58 +07:00

31 lines
1.8 KiB
Bash

#!/bin/sh
# Runs as root (via dumb-init). Fixes named-volume ownership then drops to the
# openwa user via gosu so the Node process never holds root privileges.
set -e
mkdir -p /app/data/sessions /app/data/media /app/data/plugins
chown -R openwa:openwa /app/data
# Chromium leaves SingletonLock/SingletonSocket/SingletonCookie in each session profile and does
# not remove them on an unclean shutdown; stale locks block the next launch ("profile appears to be
# in use by another Chromium process", exit Code 21). No Chromium is running yet at entrypoint time,
# so clearing them lets sessions re-launch after a crash/restart. (#259)
rm -f /app/data/sessions/*/Singleton* 2>/dev/null || true
# Chromium resolves its home from the passwd entry (no /home/openwa exists), so it hard-crashes at
# launch unless its config/cache dirs exist and are writable. XDG_CONFIG_HOME/XDG_CACHE_HOME (set in
# the image) point here; create them owned by openwa. On a read_only rootfs these live on tmpfs /tmp,
# which is mounted fresh each start — so they must be (re)created at runtime, not at build. (#254)
if ! mkdir -p "${XDG_CONFIG_HOME:-/tmp/.config}" "${XDG_CACHE_HOME:-/tmp/.cache}"; then
echo "FATAL: cannot create Chromium config/cache dirs (${XDG_CONFIG_HOME:-/tmp/.config}, ${XDG_CACHE_HOME:-/tmp/.cache})." >&2
echo " On a read_only rootfs, mount a writable tmpfs/emptyDir at /tmp (compose: 'tmpfs: [/tmp]'; k8s: an emptyDir at /tmp)." >&2
echo " Without it Chromium cannot launch and sessions will fail (#254)." >&2
exit 1
fi
chown openwa:openwa "${XDG_CONFIG_HOME:-/tmp/.config}" "${XDG_CACHE_HOME:-/tmp/.cache}"
# "$@" = CMD from Dockerfile (default: node dist/main).
# gosu performs exec, so the node process replaces this shell and becomes the
# direct child of dumb-init (PID 1), which can therefore forward SIGTERM cleanly.
exec gosu openwa "$@"