DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
chore(docker): drop now-dead gosu/libcap2-bin infra; align docs with root-supervisord model
Bingxi Zhao (Frank)8ad39f703850
diff --git a/CONTAINERIZATION.md b/CONTAINERIZATION.mdindex bd1a34713..15967c0f9 100644--- a/CONTAINERIZATION.md+++ b/CONTAINERIZATION.md@@ -43,10 +43,11 @@ no longer lives in the frontend bundle. Concretely:`data/user/settings/system.json`.- `start-frontend.sh` is now 12 lines: it sets `PORT`/`HOSTNAME` and`exec`s `node /app/web/server.js`. No mutations of the bundle.-- The entrypoint `gosu`s down to a non-root `deeptutor` user (UID 1000)- before launching `supervisord`. With `userns_mode: keep-id` on the host- that maps to your host UID; with a regular `docker run` it's a normal- unprivileged user inside the container.+- `supervisord` runs as root (PID 1) and drops each program (backend,+ frontend) to a non-root `deeptutor` user (UID 1000) via its per-program+ `user=` directive, so the app processes stay non-root. With+ `userns_mode: keep-id` on the host that UID maps to your host UID; with a+ regular `docker run` it's a normal unprivileged user inside the container.The full per-installation guide follows.@@ -166,8 +167,8 @@ host services can be reached with normal localhost URLs.For users who want the strongest default posture — rootless, with aread-only root filesystem — `compose.yaml` is the supported startingpoint. It pulls the same `ghcr.io/hkuds/deeptutor:latest` image and-relies on the entrypoint chown + `gosu` privilege drop, the URL-forwarding-`proxy.ts`, and host-side bind mounts to make it all work.+relies on the entrypoint chown + supervisord's per-program privilege drop,+the URL-forwarding `proxy.ts`, and host-side bind mounts to make it all work.```bashcp .env.example .env # then edit if needed@@ -230,9 +231,10 @@ podman run --rm -d --name deeptutor \ghcr.io/hkuds/deeptutor:latest```-After the container is up, `podman exec deeptutor id` should report-`uid=1000(deeptutor)` — the entrypoint's `gosu deeptutor supervisord`-privilege drop took effect.+After the container is up, the backend and frontend run as the non-root+`deeptutor` user — `podman exec deeptutor ps -o user,pid,comm` shows+`supervisord` as root (PID 1) with its `uvicorn`/`node` children as+`deeptutor` (UID 1000).### Known minor follow-updiff --git a/Dockerfile b/Dockerfileindex e6cec7aaf..75cec9841 100644--- a/Dockerfile+++ b/Dockerfile@@ -126,13 +126,8 @@ WORKDIR /app# Install system dependencies# Note: libgl1 and libglib2.0-0 are required for OpenCV (used by mineru)-# libcap2-bin provides `setcap`, used below to grant gosu the-# capabilities it needs to setuid/setgid inside rootless podman user-# namespaces (where the parent process doesn't have those caps).RUN apt-get update && apt-get install -y --no-install-recommends \curl \- gosu \- libcap2-bin \ca-certificates \bash \supervisor \@@ -186,16 +181,14 @@ RUN mkdir -p \data/user/logs \data/knowledge_bases-# Bake a non-root user for `gosu deeptutor supervisord` (entrypoint drops privs-# after chown'ing /app/data). UID 1000 matches the host user under rootless-# podman's `userns_mode: keep-id` with a bind mount on ./data.-# `setcap` grants gosu CAP_SETUID+CAP_SETGID so it can drop privileges-# inside rootless podman user namespaces (where the parent process-# doesn't have those caps by default).+# Bake a non-root user for the supervisord programs. supervisord runs as+# root (PID 1) and drops each child to this user via the per-program+# `user=deeptutor` directive, so the backend/frontend processes stay+# non-root. UID 1000 matches the host user under rootless podman's+# `userns_mode: keep-id` with a bind mount on ./data.RUN groupadd --system --gid 1000 deeptutor \&& useradd --system --uid 1000 --gid 1000 --no-create-home --shell /usr/sbin/nologin deeptutor \- && chown -R deeptutor:deeptutor /app/data /app/web/.next \- && setcap cap_setuid,cap_setgid+ep /usr/sbin/gosu+ && chown -R deeptutor:deeptutor /app/data /app/web/.next# Create supervisord configuration for running both services# Log output goes to stdout/stderr so docker logs can capture themdiff --git a/compose.yaml b/compose.yamlindex 5d9e8e1dd..26cb9c8a2 100644--- a/compose.yaml+++ b/compose.yaml@@ -40,10 +40,12 @@# in the image) or the restricted subprocess backend controlled by# the `sandbox_allow_subprocess` setting in system.json. See# deeptutor/services/sandbox/config.py:build_backend().-# * The image runs as a non-root `deeptutor` user (UID 1000). The-# entrypoint chowns `/app/data` and drops privileges via `gosu` before-# starting supervisord, so the running process is UID 1000 inside the-# container. Under `userns_mode: keep-id` that maps to the host user.+# * The backend and frontend run as a non-root `deeptutor` user (UID+# 1000). supervisord runs as root (PID 1), the entrypoint chowns+# `/app/data`, and each program is dropped to `deeptutor` via its+# per-program `user=` directive, so the app processes are UID 1000+# inside the container. Under `userns_mode: keep-id` that maps to the+# host user.# * URL knowledge lives in `data/user/settings/system.json` (in-network# `next_public_api_base` for the typical case, or# `next_public_api_base_external` for cloud/external). The entrypoint@@ -177,14 +179,15 @@ services:condition: service_healthynetworks:- deeptutor- # Optional hardening — uncomment to taste. The image drops privileges- # to UID 1000 via `gosu` before starting supervisord, so cap_drop ALL- # is safe in the sense that the running process has no caps anyway;- # uncomment only if you also run the sandbox-runner or similar.+ # Optional hardening — uncomment to taste. supervisord runs as root+ # (PID 1) and setuids each program down to UID 1000, which needs+ # CAP_SETUID/CAP_SETGID — so do NOT `cap_drop: ALL` here, it would stop+ # the backend/frontend from spawning. `no-new-privileges` is safe (a+ # root process dropping its own privileges is not "gaining" any).# security_opt:# - no-new-privileges:true- # cap_drop:- # - ALL+ # # cap_drop: ALL is unsafe — supervisord needs CAP_SETUID/CAP_SETGID to+ # # drop its children to the deeptutor user.# Resource limits. Honored on cgroup v2 hosts; podman warns and skips# on cgroup v1 or no-cgroup environments.# pids_limit: 1024