fix: edge hardening, rootless containers, fail-closed frontend mode

This commit is contained in:
Jonas Miederer 2026-09-14 21:35:06 +02:00
parent d903d0951f
commit e82ce391f6
15 changed files with 260 additions and 31 deletions

View file

@ -1,7 +1,7 @@
#!/bin/sh
# Frontend entrypoint (dev + prod).
# FRONTEND_MODE=dev (compose default) runs the HMR dev server.
# FRONTEND_MODE=preview (prod .env) builds once and serves the bundle.
# Fail closed: unset means the production preview server; dev sets
# FRONTEND_MODE=dev in .env (see .devcontainer/setup.sh).
set -e
cd /srv/kirche-einfach/frontend
@ -9,12 +9,13 @@ cd /srv/kirche-einfach/frontend
# node_modules lives in the repo bind-mount (no named volume by design):
# install on first start after a fresh checkout (dev and prod).
if [ ! -x "node_modules/.bin/vite" ]; then
npm ci
gosu node npm ci
fi
if [ "${FRONTEND_MODE:-dev}" = "dev" ]; then
exec npm run dev -- --host 0.0.0.0 --port 3000
if [ "${FRONTEND_MODE:-preview}" = "dev" ]; then
exec gosu node npm run dev -- --host 0.0.0.0 --port 3000
else
npm run build
exec npm run preview -- --host 0.0.0.0 --port 3000
# Build as node so dist/ stays editor-writable; preview serves as node.
gosu node npm run build
exec gosu node npm run preview -- --host 0.0.0.0 --port 3000
fi