⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
Revert "fix(docker): leave files mounted into the web root untouched"
Tin705992e758d4
diff --git a/Dockerfile.kaneo b/Dockerfile.kaneoindex 075209a42..4c8a518b4 100644--- a/Dockerfile.kaneo+++ b/Dockerfile.kaneo@@ -97,10 +97,10 @@ FROM node:24.19.0-alpine AS runtimeRUN apk add --no-cache nginx=~1.30.4 && \addgroup -g 1001 appuser && \adduser -u 1001 -G appuser -D appuser && \- mkdir -p /app /app/apps/api/data /var/lib/kaneo/html /docker-entrypoint.d && \+ mkdir -p /app /app/apps/api/data /var/lib/kaneo /docker-entrypoint.d && \chown -R appuser:appuser /app && \- chown appuser:root /var/lib/kaneo /var/lib/kaneo/html && \- chmod 2775 /var/lib/kaneo /var/lib/kaneo/html && \+ chown appuser:root /var/lib/kaneo && \+ chmod 2775 /var/lib/kaneo && \rm -rf /usr/share/nginx/html && \mkdir -p /usr/share/nginx && \ln -s /var/lib/kaneo/html /usr/share/nginx/htmldiff --git a/apps/web/Dockerfile b/apps/web/Dockerfileindex 92092bf3d..84bef02fd 100644--- a/apps/web/Dockerfile+++ b/apps/web/Dockerfile@@ -52,13 +52,12 @@ FROM nginx:1.29.5-alpine AS runtime# Only runtime storage needs write access, including for an arbitrary UID.# The legacy web root links to the rendered assets so mounted server configs-# with `root /usr/share/nginx/html` keep serving the configured app. Creating-# the target keeps files mounted through that link in a directory we own.+# with `root /usr/share/nginx/html` keep serving the configured app.RUN addgroup -g 1001 appuser && \adduser -u 1001 -G appuser -D appuser && \- mkdir -p /var/lib/kaneo/html && \- chown appuser:root /var/lib/kaneo /var/lib/kaneo/html && \- chmod 2775 /var/lib/kaneo /var/lib/kaneo/html && \+ mkdir -p /var/lib/kaneo && \+ chown appuser:root /var/lib/kaneo && \+ chmod 2775 /var/lib/kaneo && \rm -rf /usr/share/nginx/html && \ln -s /var/lib/kaneo/html /usr/share/nginx/htmldiff --git a/apps/web/env.sh b/apps/web/env.shindex 87701004c..d4db7dc33 100644--- a/apps/web/env.sh+++ b/apps/web/env.sh@@ -11,34 +11,25 @@ export KANEO_ENV_RENDERER="$script_dir/env.awk"# The image's assets stay immutable. A volume at /var/lib/kaneo also supports# read-only root filesystems and OpenShift's arbitrary runtime UID.mkdir -p "$asset_root" /var/lib/kaneo/nginx /var/lib/kaneo/tmp+cp -R "$asset_source/." "$asset_root/"+chmod -R u+rwX "$asset_root"if [ -z "${KANEO_API_URL:-}" ]; thenecho "WARNING: KANEO_API_URL is not set. API calls may fail." >&2fi-# /usr/share/nginx/html links here, so files mounted there for older images-# land in this directory. Unlinking a mount point fails, and -xdev keeps find-# out of mounted directories, so cleanup removes only the previous copies.-find /var/lib/kaneo -xdev -path "$asset_root/*" -delete 2>/dev/null || true--# Copy the build file by file, skipping paths that survived as mounts so they-# are never overwritten. find -exec preserves spaces/newlines in filenames.-find "$asset_source" -mindepth 1 -exec sh -eu -c '- asset_source=$1- shift+# find -exec preserves spaces/newlines in filenames. Write each replacement+# beside its source before atomically replacing the complete file.+find "$asset_root" -type f -name '*.js' -exec sh -eu -c 'for asset do- target="$0${asset#"$asset_source"}"- if [ -d "$asset" ]; then- mkdir -p "$target"- elif [ ! -e "$target" ] && [ ! -L "$target" ]; then- case "$asset" in- *.js) LC_ALL=C awk -v mode=bundle -f "$KANEO_ENV_RENDERER" "$asset" > "$target" ;;- *) cp "$asset" "$target" ;;- esac- chmod 644 "$target"- fi+ temporary=$(mktemp "${asset}.XXXXXX")+ trap '\''rm -f "$temporary"'\'' EXIT HUP INT TERM+ LC_ALL=C awk -v mode=bundle -f "$KANEO_ENV_RENDERER" "$asset" > "$temporary"+ chmod 644 "$temporary"+ mv "$temporary" "$asset"+ trap - EXIT HUP INT TERMdone-' "$asset_root" "$asset_source" {} ++' sh {} +# Serve JSON as static content. It must never become an nginx configuration# string, where quotes, backslashes, and dollar signs have another meaning.diff --git a/charts/kaneo/README.md b/charts/kaneo/README.mdindex 04da2f9ab..2feade689 100644--- a/charts/kaneo/README.md+++ b/charts/kaneo/README.md@@ -470,7 +470,7 @@ docker run --read-only \```For a bind mount, grant write access to the container's UID or a group it belongs to. The image's default user is UID 1001 with GID 0; arbitrary UIDs can write its runtime directory through GID 0 when the root filesystem is writable.-nginx serves the web app from `/var/lib/kaneo/html`, where startup writes the runtime configuration, and reads server configuration copied from `/etc/nginx/conf.d` into `/var/lib/kaneo/nginx/conf.d`. If you mount your own server configuration, `root /usr/share/nginx/html;` keeps working because that path now links to `/var/lib/kaneo/html`, but `root /var/lib/kaneo/html;` is recommended. The unconfigured build lives in `/usr/share/kaneo/html`; do not serve it directly. Startup copies it next to any files you mount into either web root and leaves those files untouched. With a tmpfs at `/var/lib/kaneo`, mount custom files into `/usr/share/kaneo/html` instead, because the runtime creates mount points inside a tmpfs as root. Templates in `/etc/nginx/templates` still render at startup, and `default.conf.template` replaces the bundled server configuration.+nginx serves the web app from `/var/lib/kaneo/html`, where startup writes the runtime configuration, and reads server configuration copied from `/etc/nginx/conf.d` into `/var/lib/kaneo/nginx/conf.d`. If you mount your own server configuration, `root /usr/share/nginx/html;` keeps working because that path now links to `/var/lib/kaneo/html`, but `root /var/lib/kaneo/html;` is recommended. The unconfigured build lives in `/usr/share/kaneo/html`; do not serve it directly. Templates in `/etc/nginx/templates` still render at startup, and `default.conf.template` replaces the bundled server configuration.### Registration ControlBy default, user registration is enabled. To disable new user registration:diff --git a/scripts/security/web-runtime-env.test.mjs b/scripts/security/web-runtime-env.test.mjsindex 98788280b..4cd895937 100644--- a/scripts/security/web-runtime-env.test.mjs+++ b/scripts/security/web-runtime-env.test.mjs@@ -40,7 +40,6 @@ test("production runtime serves configuration with default and restricted users"const fixture = mkdtempSync(resolve(tmpdir(), "kaneo-web-runtime-"));const runtimeImage = `kaneo-web-runtime-test:${process.pid}`;const container = `kaneo-web-runtime-test-${process.pid}`;- const volume = `kaneo-web-runtime-test-${process.pid}`;const docker = (args, timeout = 30_000) => {const result = spawnSync("docker", args, { encoding: "utf8", timeout });assert.equal(result.status, 0, result.error?.message ?? result.stderr);@@ -54,16 +53,6 @@ test("production runtime serves configuration with default and restricted users"writeFileSync(resolve(fixture, "dist", asset), '"KANEO_API_URL"');}writeFileSync(resolve(fixture, "dist/hook.js"), '"KANEO_CLIENT_URL"');- // Files mounted into the old web root must survive startup untouched,- // whether the mount is read-only or writes through to the host.- for (const asset of ["favicon.ico", "robots.txt"]) {- writeFileSync(resolve(fixture, "dist", asset), "kaneo asset");- }- const customFavicon = resolve(fixture, "favicon.ico");- writeFileSync(customFavicon, "custom favicon");- const customRobots = resolve(fixture, "robots.txt");- writeFileSync(customRobots, "custom robots", { mode: 0o666 });- chmodSync(customRobots, 0o666);const hook = resolve(fixture, "00-test.envsh");writeFileSync(hook,@@ -109,45 +98,26 @@ test("production runtime serves configuration with default and restricted users");docker(["image", "inspect", image]);docker(["build", "--network=none", "-t", runtimeImage, fixture], 120_000);- const restricted = [- "--read-only",- "--cap-drop=ALL",- "--security-opt=no-new-privileges",- ];- // The runtime creates a tmpfs's mount points as root, so custom files go- // in the build directory there; the old web root works everywhere else.for (const scenario of [{name: "default non-root user",uid: "1001",- assets: "/usr/share/nginx/html",args: [],},{name: "arbitrary OpenShift UID",uid: "1001230000",- assets: "/usr/share/nginx/html",args: ["--user=1001230000:0"],},{name: "arbitrary UID and read-only root with writable volume",uid: "1001230000",- assets: "/usr/share/kaneo/html",args: ["--user=1001230000:1001230000",+ "--read-only","--tmpfs=/var/lib/kaneo:rw,mode=0770,gid=1001230000",- ...restricted,- ],- },- {- name: "arbitrary UID and read-only root with named volume",- uid: "1001230000",- assets: "/usr/share/nginx/html",- args: [- "--user=1001230000:0",- "--mount",- `type=volume,source=${volume},target=/var/lib/kaneo`,- ...restricted,+ "--cap-drop=ALL",+ "--security-opt=no-new-privileges",],},]) {@@ -166,10 +136,6 @@ test("production runtime serves configuration with default and restricted users"`type=bind,source=${template},target=/etc/nginx/templates/runtime.conf.template,readonly`,"--mount",`type=bind,source=${legacy},target=/etc/nginx/conf.d/legacy.conf,readonly`,- "--mount",- `type=bind,source=${customFavicon},target=${scenario.assets}/favicon.ico,readonly`,- "--mount",- `type=bind,source=${customRobots},target=${scenario.assets}/robots.txt`,"--env","KANEO_API_URL=https://api.example.test/api",runtimeImage,@@ -178,7 +144,7 @@ test("production runtime serves configuration with default and restricted users""-c",[`test "$(id -u)" = ${scenario.uid}`,- "test ! -e /var/lib/kaneo/html/root.js",+ "test ! -d /var/lib/kaneo/html","test -L /usr/share/nginx/html",'test "$(cat /usr/share/kaneo/html/root.js)" = \'"KANEO_API_URL"\'',"/docker-entrypoint.sh nginx -t",@@ -194,9 +160,6 @@ test("production runtime serves configuration with default and restricted users"'test "$(wget -qO- http://127.0.0.1:5173/)" = "runtime fixture"','test "$(wget -qO- http://127.0.0.1:5174/)" = "https://hook.example.test"','test "$(wget -qO- http://127.0.0.1:5175/root.js)" = \'"https://api.example.test/api"\'',- 'test "$(wget -qO- http://127.0.0.1:5173/favicon.ico)" = "custom favicon"',- 'test "$(wget -qO- http://127.0.0.1:5175/favicon.ico)" = "custom favicon"',- 'test "$(wget -qO- http://127.0.0.1:5175/robots.txt)" = "custom robots"',"wget -qO- http://127.0.0.1:5173/root.js","wget -qO- http://127.0.0.1:5173/assets/app.js","wget -qO- http://127.0.0.1:5173/.well-known/oauth-protected-resource/api/mcp",@@ -213,13 +176,10 @@ test("production runtime serves configuration with default and restricted users"assert.equal(responses[1], "https://api.example.test/api");assert.equal(responses[2].resource, "https://api.example.test/api/mcp");assert.equal(responses[3].issuer, "https://api.example.test/api");- assert.equal(readFileSync(customFavicon, "utf8"), "custom favicon");- assert.equal(readFileSync(customRobots, "utf8"), "custom robots");});}} finally {spawnSync("docker", ["rm", "-f", container], { timeout: 30_000 });- spawnSync("docker", ["volume", "rm", volume], { timeout: 30_000 });spawnSync("docker", ["image", "rm", runtimeImage], { timeout: 30_000 });rmSync(fixture, { recursive: true, force: true });}