A local-first multi-agent app development platform, built on PenguinHarness
feat(ci,docs): an official Docker image, published from the release workflow (#609)
Yaowei Zheng8b94dcb08b21
diff --git a/.dockerignore b/.dockerignorenew file mode 100644index 00000000..8c07cfbd--- /dev/null+++ b/.dockerignore@@ -0,0 +1,42 @@+# The image is built from this repository's source, so the context is the working tree+# minus what the build must not see: dependencies and output it produces itself, artifacts+# a developer's machine leaves lying around, and the local-only files a working copy+# carries. Every entry here is also one fewer thing that can differ between two builds of+# the same commit and needlessly invalidate the COPY layer.++# History, and the workflows that drive the build from outside it. The absence of .git is+# also why the artifact carries no git stamp of its own: the commit reaches it through the+# PENGUIN_COMMIT build arg instead.+.git+.gitattributes+.github++# Installed and generated by the build itself.+**/node_modules+**/dist+**/*.tsbuildinfo+packages/server/web-dist+packages/desktop/out+packages/desktop/stage+.turbo++# Artifacts of running things locally.+**/test-results+**/playwright-report+packages/landing/.blog-assets+**/*.log++# Local configuration, and the symlinks a development checkout carries to reach the design+# repository — absent from a CI checkout, and dangling anywhere else.+.env+.env.*+!.env.example+design+AGENTS.md+CLAUDE.md++# Editor and OS leftovers.+.DS_Store+.idea+.vscode+**/*.swpdiff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.mdindex e886476c..34721186 100644--- a/.github/CONTRIBUTING.md+++ b/.github/CONTRIBUTING.md@@ -160,6 +160,15 @@ pnpm test:e2e # core live-model e2e, needbefore creating the tag** — the release workflow reads it from the tag's checkout, so afile added later never reaches the Release page. Without it the workflow falls back toGitHub's auto-generated notes.+- **The official image is built from source**, by `.github/workflows/docker.yml`, and+ pushed to Docker Hub `hiyouga/penguinharness` for `linux/amd64` and `linux/arm64`. Every+ push to `main` publishes that commit as `latest` and as `main-<sha7>`; the release+ workflow's `docker` job builds the tag's own source and publishes `X.Y.Z`, `X.Y` and —+ while the tag is the current latest Release — `stable`. A PR touching the `Dockerfile`,+ `docker/` or that workflow runs the same file as an amd64 smoke build. The push+ needs the `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` secrets of the `docker` GitHub Environment (whose URL is the Docker Hub repository) — the latter a+ Docker Hub access token with read/write scope on that repository — and the Docker Hub+ repository is created public on the first push.- **Release prep bumps the repo version**: the same `release: X.Y.Z` PR that renames`changelog/unreleased/` also bumps the root and every `packages/*/package.json``version`, plus core's `VERSION` constant (`packages/core/src/index.ts`), to the releasediff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlnew file mode 100644index 00000000..b84e3e63--- /dev/null+++ b/.github/workflows/docker.yml@@ -0,0 +1,292 @@+# Docker: build the official image from this repository's source and publish it to Docker Hub.+#+# Four entry points, two jobs:+# - pull_request touching the image's own files: `smoke` builds for amd64 and actually runs the+# container — readiness, sign-in, the healthcheck, the unprivileged user, a graceful stop and a+# restart onto the same data root. It builds the PR's own checkout, so it proves the Dockerfile+# against the code the PR carries.+# - push to main: `publish` builds that commit and moves `latest`, alongside an immutable+# `main-<sha7>` twin. Every push, no path filter — `latest` follows main.+# - workflow_call from release.yml's `docker` job: the same build at the tag, published as+# `X.Y.Z`, `X.Y` and `stable`.+# - workflow_dispatch for a manual re-publish, mirroring release.yml's own dispatch input.+name: Docker++on:+ workflow_call:+ inputs:+ tag:+ description: "Release tag to build and publish (e.g. v0.1.0); the image is built from that tag's source"+ required: true+ type: string+ push:+ description: "Push to Docker Hub (false builds without publishing)"+ required: false+ default: false+ type: boolean+ workflow_dispatch:+ inputs:+ tag:+ description: "Release tag to build and publish (e.g. v0.1.0); the image is built from that tag's source"+ required: true+ type: string+ push:+ description: "Push to Docker Hub (false builds without publishing)"+ required: false+ default: true+ type: boolean+ push:+ branches: [main]+ pull_request:+ paths:+ - Dockerfile+ - .dockerignore+ - docker/**+ - .github/workflows/docker.yml++concurrency:+ group: docker-${{ github.event_name }}-${{ github.ref }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}++env:+ IMAGE_NAME: hiyouga/penguinharness++jobs:+ # Build once and put the container through the contract the docs promise. Only amd64: this+ # job exists to catch a broken Dockerfile in minutes, and the arm64 leg of a publish build+ # compiles node-pty under QEMU.+ smoke:+ name: Build and run (amd64)+ if: github.event_name == 'pull_request'+ runs-on: ubuntu-latest+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@v5++ - uses: docker/setup-buildx-action@v3++ - name: Build the image+ uses: docker/build-push-action@v6+ with:+ context: .+ load: true+ tags: penguin-harness:pr+ build-args: |+ PENGUIN_VERSION=pr+ PENGUIN_COMMIT=${{ github.sha }}+ cache-from: type=gha+ cache-to: type=gha,mode=max++ # Nothing about the image is root-only, so the entrypoint's privilege drop is observable+ # from a one-off run: `id -u` goes through the same entrypoint the server does.+ - name: Entrypoint drops to uid 1000+ run: |+ uid="$(docker run --rm penguin-harness:pr id -u)"+ echo "entrypoint ran the command as uid $uid"+ [ "$uid" = "1000" ]++ - name: Start the container+ run: |+ docker run -d --name penguin -p 127.0.0.1:7364:7364 \+ -e PENGUIN_SEED_ADMIN_PASSWORD=ci-password-123 \+ -v penguin-data:/data \+ penguin-harness:pr++ - name: Wait for the server+ run: |+ for _ in $(seq 1 90); do+ if curl -fsS http://127.0.0.1:7364/api/install > /tmp/install.json; then+ jq -e '.installId | type == "string" and (. | length) > 0' /tmp/install.json+ exit 0+ fi+ sleep 1+ done+ echo "error: the server did not answer /api/install within 90s" >&2+ docker logs penguin >&2+ exit 1++ # The pinned seed password suppresses the first-login notice, so a successful login is+ # what proves the seed ran; /api/version then proves the session cookie is usable.+ - name: Sign in and read the version+ run: |+ code="$(curl -s -o /tmp/login.json -w '%{http_code}' -c /tmp/cookies.txt \+ -H 'content-type: application/json' \+ -d '{"userId":"admin","password":"ci-password-123"}' \+ http://127.0.0.1:7364/api/auth/login)"+ if [ "$code" != "200" ]; then+ echo "error: login answered $code" >&2+ cat /tmp/login.json >&2+ exit 1+ fi+ curl -fsS -b /tmp/cookies.txt http://127.0.0.1:7364/api/version > /tmp/version.json+ jq -e '.version | type == "string"' /tmp/version.json++ # web.db was created by the server itself, so its owner is the euid the server runs as.+ - name: Data root belongs to the unprivileged user+ run: |+ owners="$(docker exec penguin stat -c '%n %u:%g' /data /data/web.db)"+ echo "$owners"+ [ "$(docker exec penguin stat -c %u /data)" = "1000" ]+ [ "$(docker exec penguin stat -c %u /data/web.db)" = "1000" ]++ - name: HEALTHCHECK reports healthy+ run: |+ for _ in $(seq 1 90); do+ status="$(docker inspect -f '{{.State.Health.Status}}' penguin)"+ if [ "$status" = "healthy" ]; then exit 0; fi+ if [ "$status" = "unhealthy" ]; then break; fi+ sleep 1+ done+ echo "error: healthcheck ended in '$status'" >&2+ docker inspect -f '{{json .State.Health}}' penguin >&2+ exit 1++ # tini forwards SIGTERM to `penguin server`, which forwards it to the service child; the+ # service interrupts running Tasks, waits for them to wrap up and closes the database.+ # An idle server has nothing to drain, so this is a matter of a second, not the grace period.+ - name: Stops gracefully+ run: |+ start="$(date +%s)"+ docker stop -t 30 penguin+ elapsed="$(( $(date +%s) - start ))"+ code="$(docker inspect -f '{{.State.ExitCode}}' penguin)"+ echo "stopped in ${elapsed}s with exit code $code"+ [ "$code" = "0" ]+ [ "$elapsed" -lt 15 ]++ # The lock left behind by the stopped process must not refuse the next start, and the+ # data root must come back with its user intact rather than being seeded a second time.+ - name: Restarts onto the same data root+ run: |+ docker start penguin+ for _ in $(seq 1 90); do+ if curl -fsS http://127.0.0.1:7364/api/install > /dev/null; then break; fi+ sleep 1+ done+ code="$(curl -s -o /dev/null -w '%{http_code}' \+ -H 'content-type: application/json' \+ -d '{"userId":"admin","password":"ci-password-123"}' \+ http://127.0.0.1:7364/api/auth/login)"+ if [ "$code" != "200" ]; then+ echo "error: login after restart answered $code" >&2+ docker logs penguin >&2+ exit 1+ fi++ - name: Container log+ if: always()+ run: docker logs penguin || true++ publish:+ name: Build and push+ if: github.event_name != 'pull_request'+ runs-on: ubuntu-latest+ permissions:+ contents: read+ # The Docker Hub credentials live in the `docker` GitHub Environment, whose URL is the+ # published repository, so they reach this job alone — the smoke job and the rest of CI+ # never see them.+ environment:+ name: docker+ url: https://hub.docker.com/r/hiyouga/penguinharness+ steps:+ # A release build must come from the TAG's source, not from whatever branch the run was+ # started on: `inputs.tag` is set for workflow_call and workflow_dispatch and empty for a+ # push to main, where the default ref is already the commit to build.+ - uses: actions/checkout@v5+ with:+ ref: ${{ inputs.tag || '' }}++ # Two tag policies.+ #+ # A push to main publishes `latest` plus an immutable `main-<sha7>` twin, so `latest` always+ # names the newest build and anyone who needs to pin one can.+ #+ # A release publishes the exact version, `X.Y` for a plain X.Y.Z tag (a prerelease has no+ # meaningful minor line to move), and `stable` — resolved in the next step — for readers who+ # want releases only. The commit comes from the checkout rather than from github.sha, which+ # on a dispatch names the branch the run was started on and not the tag.+ - name: Resolve the version and its tags+ id: version+ env:+ EVENT: ${{ github.event_name }}+ TAG: ${{ inputs.tag }}+ run: |+ COMMIT="$(git rev-parse HEAD)"+ echo "commit=$COMMIT" >> "$GITHUB_OUTPUT"+ if [ "$EVENT" = "push" ]; then+ echo "version=main-$(printf '%s' "$COMMIT" | cut -c1-7)" >> "$GITHUB_OUTPUT"+ echo "minor=" >> "$GITHUB_OUTPUT"+ echo "latest=true" >> "$GITHUB_OUTPUT"+ exit 0+ fi+ V="${TAG#v}"+ echo "version=$V" >> "$GITHUB_OUTPUT"+ echo "latest=false" >> "$GITHUB_OUTPUT"+ if printf '%s' "$V" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then+ echo "minor=${V%.*}" >> "$GITHUB_OUTPUT"+ else+ echo "minor=" >> "$GITHUB_OUTPUT"+ echo "$TAG is not a plain X.Y.Z tag; publishing the exact version only."+ fi++ # `stable` moves only when the tag is GitHub's current latest Release, so re-publishing an+ # older tag cannot demote the newest release image.+ - name: Determine whether the tag is the latest Release+ id: stable+ if: github.event_name != 'push'+ env:+ GH_TOKEN: ${{ github.token }}+ TAG: ${{ inputs.tag }}+ run: |+ LATEST_TAG="$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName --jq .tagName)"+ if [ "$TAG" = "$LATEST_TAG" ]; then+ echo "update=true" >> "$GITHUB_OUTPUT"+ else+ echo "update=false" >> "$GITHUB_OUTPUT"+ echo "$TAG will be published without moving :stable (current latest: $LATEST_TAG)."+ fi++ # arm64 is emulated: the image is built on one x64 runner, and only the stage that compiles+ # node-pty runs under QEMU on that leg — the workspace build itself stays on the build+ # platform (see the Dockerfile).+ - uses: docker/setup-qemu-action@v3++ - uses: docker/setup-buildx-action@v3++ # Docker Hub is the default registry, so the login needs no `registry:`. The two secrets,+ # DOCKERHUB_USERNAME and DOCKERHUB_TOKEN — a Docker Hub access token with read/write scope+ # on that repository — belong to the `docker` environment declared on this job.+ - uses: docker/login-action@v3+ with:+ username: ${{ secrets.DOCKERHUB_USERNAME }}+ password: ${{ secrets.DOCKERHUB_TOKEN }}++ - name: Image tags and labels+ id: meta+ uses: docker/metadata-action@v5+ with:+ images: ${{ env.IMAGE_NAME }}+ tags: |+ type=raw,value=${{ steps.version.outputs.version }}+ type=raw,value=${{ steps.version.outputs.minor }},enable=${{ steps.version.outputs.minor != '' }}+ type=raw,value=latest,enable=${{ steps.version.outputs.latest == 'true' }}+ type=raw,value=stable,enable=${{ steps.stable.outputs.update == 'true' }}++ # provenance is off: the attestation manifest it attaches shows up in the package listing as+ # an "unknown/unknown" platform, which is worse for a reader than the attestation is worth.+ - name: Build and push+ uses: docker/build-push-action@v6+ with:+ context: .+ platforms: linux/amd64,linux/arm64+ push: ${{ github.event_name == 'push' || inputs.push }}+ tags: ${{ steps.meta.outputs.tags }}+ labels: ${{ steps.meta.outputs.labels }}+ build-args: |+ PENGUIN_VERSION=${{ steps.version.outputs.version }}+ PENGUIN_COMMIT=${{ steps.version.outputs.commit }}+ cache-from: type=gha+ cache-to: type=gha,mode=max+ provenance: falsediff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex bb760a17..e8e853c6 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -38,6 +38,10 @@# to immutable releases/<tag>/ keys in Alibaba Cloud OSS through GitHub OIDC. The GitHub Environment# `oss-production` supplies the provider/role ARNs and OSS settings. latest.json is uploaded last and only# when the tag is still GitHub's current latest Release. Manual retries also work after a Release exists.+# - docker: build and push the official image (Docker Hub hiyouga/penguinharness, linux/amd64 ++# linux/arm64) from the tag's own source, independently of npm. The build/publish steps live in+# docker.yml, which the same PR-time smoke job exercises and which also publishes `latest` from+# every push to main; this workflow only decides when the release tags are published.name: Releaseon:@@ -645,3 +649,20 @@ jobs:fipnpm --filter "$name" publish --access public --no-git-checksdone++ # The image is built from the tag's source and installs nothing from npm, so this no longer waits+ # for publish-npm. It is gated like mirror-oss, because a dispatch of an already-released tag must+ # still be able to (re)publish the image: `release` skipped is as good as `release` succeeded.+ docker:+ name: Publish the official Docker image+ needs: [check-release, release]+ if: >-+ ${{ always() && needs.check-release.result == 'success' &&+ (needs.release.result == 'success' || needs.release.result == 'skipped') }}+ permissions:+ contents: read+ uses: ./.github/workflows/docker.yml+ with:+ tag: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}+ push: true+ secrets: inheritdiff --git a/Dockerfile b/Dockerfilenew file mode 100644index 00000000..b56ec119--- /dev/null+++ b/Dockerfile@@ -0,0 +1,264 @@+# The official PenguinHarness server image: `penguin server` on 0.0.0.0:7364, serving the+# Web App, with the data root at /data.+#+# docker build -t penguin-harness:dev .+# docker run -d -p 127.0.0.1:7364:7364 -v penguin-data:/data penguin-harness:dev+#+# Published from .github/workflows/docker.yml to Docker Hub as hiyouga/penguinharness.+# The user-facing contract (first sign-in, volumes, upgrades, reverse proxies) is+# documented in packages/docs/content/quickstart-docker.en.md.+#+# The program is built from this repository's source, by the recipe release.yml assembles+# the shipped CLI with: install the workspace, build the packages the server needs,+# `pnpm deploy` a production dependency tree into lib/, and put the built web assets beside+# it in web/. Nothing is installed from npm, so an image can carry an unreleased commit —+# which is what lets every push to main publish one.+#+# Three stages, split by WHERE each one has to run:+# - `build` is pinned to the BUILD platform. TypeScript and Vite emit the same bytes on any+# machine, so running a whole workspace install and build under QEMU for the arm64 leg+# would cost many minutes and buy nothing.+# - `native` runs on the TARGET platform, for the one thing that is architecture-specific:+# node-pty's C++ binding, which is published for darwin and win32 only and therefore+# compiles on every Linux install. It is the only compiled dependency in the CLI's+# production tree — the rest is JavaScript, and the database is Node's own node:sqlite.+# - the runtime stage copies the result and never installs a compiler.+#+# Ubuntu rather than the `node:` images: it is what the CI runners are, so an image+# compiles native bindings against the glibc every release artifact was built on, and it+# is the environment the skills library assumes when an agent runs `apt-get`. The cost is+# that the Node runtime is installed here, pinned by hand — keep NODE_VERSION in step with+# `NODE_RUNTIME_VERSION` in .github/workflows/release.yml, which pins the runtime the+# release tarballs bundle. (The per-agent export template in core still renders its own+# `node:24-slim` Dockerfile; the intended convergence is for it to derive FROM this image+# and add only its bundle and entrypoint.)++ARG NODE_VERSION=24.18.0++# --- base: Ubuntu + the official Node runtime, shared by every stage below ---+FROM ubuntu:24.04 AS base++# git and curl are for the agent's own tools (cloning repositories, reaching HTTPS) and+# curl additionally serves the healthcheck; xz-utils unpacks the Node tarball below; tini+# reaps the orphans an agent's shell commands leave behind, which Node as PID 1 would not.+RUN set -eux; \+ apt-get update; \+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \+ ca-certificates \+ curl \+ git \+ tini \+ xz-utils; \+ rm -rf /var/lib/apt/lists/*++ARG NODE_VERSION++# The official nodejs.org build, verified against the release's own SHASUMS256.txt. The+# checksum file travels the same TLS connection as the tarball, so this catches a+# truncated or corrupted download rather than a compromised nodejs.org; verifying the+# signature on SHASUMS256.txt would mean carrying and rotating the release keys.+#+# The architecture is read out of the container this stage is running IN rather than from+# TARGETARCH, because this stage is instantiated on two different platforms: `build` below+# pins itself to the build platform, and TARGETARCH there still names the platform the image+# is being built FOR — it would have that stage install an arm64 runtime onto an amd64 machine.+#+# The tarball's C++ headers (65 MB of /usr/local/include/node) go: nothing here compiles+# against them — node-gyp downloads its own copy for the version it is building for.+RUN set -eux; \+ arch="$(dpkg --print-architecture)"; \+ case "$arch" in \+ amd64) node_arch=x64 ;; \+ arm64) node_arch=arm64 ;; \+ *) echo "unsupported architecture: $arch" >&2; exit 1 ;; \+ esac; \+ archive="node-v${NODE_VERSION}-linux-${node_arch}.tar.xz"; \+ cd /tmp; \+ curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/${archive}"; \+ curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt"; \+ awk -v want="$archive" '$2 == want' SHASUMS256.txt > node.sha256; \+ test -s node.sha256; \+ sha256sum -c node.sha256; \+ tar -xJf "$archive" -C /usr/local --strip-components=1 --no-same-owner; \+ rm -f "$archive" SHASUMS256.txt node.sha256; \+ rm -rf /usr/local/include/node; \+ node --version; \+ npm --version++# --- build: the workspace, built once on the build platform ---+FROM --platform=$BUILDPLATFORM base AS build++# pnpm compiles node-pty for the build platform while installing. That copy is thrown away+# with this stage — `native` below compiles the one that ships — but the toolchain still+# has to be here for the install to get through.+RUN set -eux; \+ apt-get update; \+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \+ g++ \+ make \+ python3; \+ rm -rf /var/lib/apt/lists/*++WORKDIR /src++# The context is the working tree minus dependencies, build output and local artifacts;+# .dockerignore says which and why.+COPY . .++# pnpm at the version the repository pins in `packageManager`, read out of that field so+# there is no second copy to keep in step. npm rather than corepack: corepack checks the+# download against signing keys baked into the Node build, which turns a pnpm release newer+# than the runtime into a failure that has nothing to do with this repository.+RUN set -eux; \+ npm install -g "$(node -p 'require("./package.json").packageManager')"; \+ npm cache clean --force; \+ pnpm --version++ARG PENGUIN_COMMIT++# The commit is what tells two builds of the same version apart, and a bundle carries no+# path back to the checkout it came from. This is the stamp release.yml applies before it+# builds; VERSION is deliberately left alone, because a build from main is not a release+# and the image's own version is a label. BRE: the unescaped | in these patterns is literal.+RUN set -eux; \+ if [ -n "$PENGUIN_COMMIT" ]; then \+ grep -q 'export const BUILD_COMMIT: string | null = ' packages/core/src/index.ts; \+ sed -i "s/export const BUILD_COMMIT: string | null = [^;]*/export const BUILD_COMMIT: string | null = \"$PENGUIN_COMMIT\"/" packages/core/src/index.ts; \+ grep -Fq "export const BUILD_COMMIT: string | null = \"$PENGUIN_COMMIT\"" packages/core/src/index.ts; \+ fi++# The desktop package is part of the workspace and its install script would fetch a ~150 MB+# Electron runtime this image never launches.+ENV ELECTRON_SKIP_BINARY_DOWNLOAD=1++# `<pkg>...` selects a package together with its workspace dependencies, so the CLI filter+# pulls core, server and the @penguinharness/* plugin packages in topological order; web is+# named separately because nothing depends on it — its dist is what web/ ships. The rest of+# the workspace (desktop, docs, landing) is installed but never built.+#+# --config.verify-deps-before-run goes BEFORE the command: after it, pnpm forwards the flag+# to the script instead of reading it. The check wants a terminal to prompt at, and a Docker+# build has none.+RUN set -eux; \+ pnpm install --frozen-lockfile; \+ pnpm --config.verify-deps-before-run=false \+ --filter "@prismshadow/penguin-cli..." \+ --filter "@prismshadow/penguin-web" \+ build++# The payload layout every release artifact uses, and the one scripts/launchers/penguin+# spells out: lib/ is the CLI with its production dependencies, web/ the built front end.+# Deployed inside the workspace and moved afterwards, which is release.yml's line verbatim.+# The hoisted node-linker is part of that recipe — it keeps paths short enough for Windows,+# and it is the layout `npm rebuild` walks in the next stage.+RUN set -eux; \+ pnpm --config.node-linker=hoisted --filter @prismshadow/penguin-cli --prod deploy "$PWD/out/penguin/lib"; \+ cp -r packages/web/dist out/penguin/web; \+ mkdir -p /opt/penguin; \+ mv out/penguin/lib /opt/penguin/lib; \+ mv out/penguin/web /opt/penguin/web; \+ test -f /opt/penguin/lib/dist/penguin.js; \+ test -f /opt/penguin/web/index.html++# --- native: recompile what depends on the architecture, on the target platform ---+FROM base AS native++RUN set -eux; \+ apt-get update; \+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \+ g++ \+ make \+ python3; \+ rm -rf /var/lib/apt/lists/*++COPY --from=build /opt/penguin /opt/penguin++# node-pty's install script is `node scripts/prebuild.js || node-gyp rebuild`, and the+# prebuilds it publishes are darwin and win32 only, so on Linux the fallback compiles.+# build/ is removed first so that a rebuild which quietly did nothing cannot pass unnoticed:+# without that, the amd64 leg would still be carrying the binding the build stage produced+# and only the arm64 leg would break — on a push to main, long after the pull request that+# introduced the break went green.+#+# Dropping prebuilds/ saves ~58 MB of macOS and Windows bindings a Linux image can never+# load. It stays conditional on the binding this stage just compiled: a future node-pty that+# DOES publish a linux prebuild would skip the compile, and deleting the directory would+# then leave nothing to load.+#+# The require() is the proof rather than a formality — node-pty loads its binding at import+# time, so one built for the wrong architecture fails here instead of at the first Task.+RUN set -eux; \+ cd /opt/penguin/lib; \+ rm -rf node_modules/node-pty/build; \+ npm rebuild --foreground-scripts node-pty; \+ if [ -f node_modules/node-pty/build/Release/pty.node ]; then \+ rm -rf node_modules/node-pty/prebuilds; \+ fi; \+ node --input-type=commonjs -e 'require("node-pty")'++# --- runtime ---+FROM base++ARG PENGUIN_VERSION=dev+ARG PENGUIN_COMMIT++LABEL org.opencontainers.image.title="PenguinHarness" \+ org.opencontainers.image.description="PenguinHarness server and Web App" \+ org.opencontainers.image.url="https://penguin.ooo" \+ org.opencontainers.image.source="https://github.com/Prism-Shadow/penguin-harness" \+ org.opencontainers.image.licenses="Apache-2.0" \+ org.opencontainers.image.version="${PENGUIN_VERSION}" \+ org.opencontainers.image.revision="${PENGUIN_COMMIT}"++# One directory carries the CLI, the server, the plugin packages, the built web assets and+# the node-pty binding compiled for this architecture.+#+# `penguin` is a symlink straight to the entry script rather than a copy of+# scripts/launchers/penguin, and that is a behaviour rather than a shortcut: the launcher+# would hand node a path ending in .js, and the server reads such a path as a re-runnable+# CLI entry — it would then offer in-container self-update, which installs into a filesystem+# the next `docker pull` throws away. Through the symlink argv[1] is /usr/local/bin/penguin,+# extensionless, so the entry stays unset and the update endpoint answers "unsupported".+# PENGUIN_WEB_DIST below is the other half of what that launcher would have done.+COPY --from=native /opt/penguin /opt/penguin+RUN set -eux; \+ chmod 0755 /opt/penguin/lib/dist/penguin.js; \+ ln -s /opt/penguin/lib/dist/penguin.js /usr/local/bin/penguin; \+ PENGUIN_HOME=/tmp/penguin-smoke penguin --version; \+ rm -rf /tmp/penguin-smoke++# ubuntu:24.04 ships a stock `ubuntu` account already holding uid/gid 1000 — the id a host+# user's bind mount most often carries — so it makes way for `penguin`. groupadd fails+# loudly if the id is still taken, which is what keeps the tolerant userdel above honest.+RUN set -eux; \+ userdel -r ubuntu 2>/dev/null || userdel ubuntu 2>/dev/null || true; \+ groupadd --gid 1000 penguin; \+ useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash penguin++# HOME is set explicitly because the entrypoint drops privileges with setpriv, which+# replaces the process's ids without rewriting its environment: without this the server+# would run as `penguin` while still pointed at root's home.+ENV HOME=/home/penguin \+ PENGUIN_HOME=/data \+ PENGUIN_WEB_DIST=/opt/penguin/web \+ HOST=0.0.0.0 \+ PORT=7364++WORKDIR /home/penguin++RUN set -eux; \+ mkdir -p /data; \+ chown penguin:penguin /data+VOLUME ["/data"]++EXPOSE 7364++COPY --chmod=0755 docker/entrypoint.sh /usr/local/bin/penguin-entrypoint++# GET /api/install is public and needs no session, which is why it and not a page is the+# probe. It reads one small file per request, so it also fails when the data root is gone.+HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \+ CMD curl -fsS "http://127.0.0.1:${PORT}/api/install" || exit 1++ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/penguin-entrypoint"]+CMD ["penguin", "server"]diff --git a/README.md b/README.mdindex 95a0709b..58826e49 100644--- a/README.md+++ b/README.md@@ -119,7 +119,7 @@ Each family's latest generation only — the app's **Models** page lists every b## Installation-Start with the desktop app, or install the command line on a workstation or server. Both use the same `~/.penguin/data` root and can be mixed freely:+Start with the desktop app, or install the command line on a workstation or server. Both use the same `~/.penguin/data` root and can be mixed freely; a server is also one `docker run` away:- **🖥️ Desktop app** — a double-click install: it embeds the server and opens already signed in, no terminal involved.- **⌨️ CLI** — a one-line installer (or npm / offline package) puts the `penguin` command on the machine; `penguin web` then serves the full Web experience in your browser at `http://127.0.0.1:7364` (multi-session chat, agent / skill / model management, usage stats, Trace observability, evaluation center). The online installers bundle their own Node runtime — unpack and run; upgrades and reinstalls never touch your data.@@ -173,6 +173,15 @@ npm install -g @prismshadow/penguin-clipenguin web # start the service and open http://127.0.0.1:7364```+### 🐳 Docker++```bash+docker run -d --name penguin -p 127.0.0.1:7364:7364 -v penguin-data:/data hiyouga/penguinharness:latest+docker logs penguin # the first-login link, openable as it stands on this machine+```++The official image runs the same server on `0.0.0.0:7364` with its data root on the `/data` volume, as an unprivileged user, for `linux/amd64` and `linux/arm64`. It is built from this repository's source: `latest` is rebuilt on every push to `main`, and `stable` follows the newest release. The example publishes the port on the host's loopback, so the Web App answers only on the machine running Docker (`http://localhost:7364`); to reach it from a network, publish on all interfaces instead (`-p 7364:7364`), preferably behind a reverse proxy that terminates TLS. Compose file and the full deployment notes — reverse proxies, upgrades, the rescue path — are in the [Docker quickstart](https://penguin.ooo/docs/quickstart-docker).+<details><summary><b>📴 Offline install (air-gapped machines)</b></summary>diff --git a/README.zh.md b/README.zh.mdindex fac2b4d4..0ef2b765 100644--- a/README.zh.md+++ b/README.zh.md@@ -119,7 +119,7 @@ https://github.com/user-attachments/assets/aec49ae9-b743-467b-b247-37bedfeaa36e## 安装-优先使用桌面端,也可以在本地电脑或服务器上安装命令行。两种方式共用 `~/.penguin/data` 目录,可自由混用:+优先使用桌面端,也可以在本地电脑或服务器上安装命令行。两种方式共用 `~/.penguin/data` 目录,可自由混用;服务端也可以一条 `docker run` 起来:- **🖥️ 桌面端应用**——双击安装:内嵌服务端,打开即已登录,全程无需终端。- **⌨️ 命令行**——一行命令(或 npm / 离线包)装出 `penguin` 命令,`penguin web` 即在浏览器打开完整 Web 体验 `http://127.0.0.1:7364`(多会话对话、Agent / 技能 / 模型管理、用量统计、轨迹观测、评估中心)。在线安装器自带 Node 运行时,解压即用;升级与重装不触碰数据。@@ -173,6 +173,15 @@ npm install -g @prismshadow/penguin-clipenguin web # 启动服务并打开 http://127.0.0.1:7364```+### 🐳 Docker++```bash+docker run -d --name penguin -p 127.0.0.1:7364:7364 -v penguin-data:/data hiyouga/penguinharness:latest+docker logs penguin # 首次登录链接,在本机可原样打开+```++官方镜像以非特权用户在 `0.0.0.0:7364` 上运行同一个服务端,数据目录落在 `/data` 卷上,提供 `linux/amd64` 与 `linux/arm64`。镜像由本仓库源码构建:`latest` 在每次 push `main` 时重建,`stable` 跟随最新的发布版。示例把端口发布在宿主机回环上,因此 Web 应用只在运行 Docker 的那台机器上可达(`http://localhost:7364`);要从网络访问,改为发布到所有接口(`-p 7364:7364`),并尽量置于终结 TLS 的反向代理之后。compose 文件与完整部署说明(反向代理、升级、救援路径)见 [Docker 快速开始](https://penguin.ooo/docs/quickstart-docker)。+<details><summary><b>📴 离线安装(无网环境)</b></summary>diff --git a/changelog/unreleased/2026-09-04-official-docker-image.md b/changelog/unreleased/2026-09-04-official-docker-image.mdnew file mode 100644index 00000000..29f8955a--- /dev/null+++ b/changelog/unreleased/2026-09-04-official-docker-image.md@@ -0,0 +1,19 @@+# An official Docker image, built from source++- **Date:** 2026-09-04+- **Type:** feature+- **Scope:** `ci`, `tooling`, `docs`+- **PR:** [#609](https://github.com/Prism-Shadow/penguin-harness/pull/609)++[中文版](2026-09-04-official-docker-image.zh.md)++PenguinHarness gained an official container image, Docker Hub `hiyouga/penguinharness`, built from this repository's source for `linux/amd64` and `linux/arm64`. Every push to `main` publishes that commit as `latest`, with `main-<sha7>` as an immutable twin; a release publishes `X.Y.Z`, `X.Y`, and `stable` while the tag is GitHub's current latest Release. It runs `penguin server` on `0.0.0.0:7364` with the data root on a `/data` volume, so a deployment is one container and one volume. The compose file and every documented `docker run` publish the port on the host's loopback (`127.0.0.1:7364:7364`), which leaves a fresh deployment reachable only from the machine running Docker; opening it to a network is an explicit choice, documented alongside the reverse-proxy notes.++## Details++- The image is built by the recipe that assembles the shipped CLI: install the workspace, build the packages the server needs, `pnpm deploy` a production dependency tree into `/opt/penguin/lib`, and put the built web assets beside it in `/opt/penguin/web`. The stages split by where each has to run — the workspace build is pinned to the build platform, because TypeScript and Vite emit the same bytes on any machine, and a second stage on the target platform recompiles `node-pty`, the only compiled dependency in that tree and one that publishes no Linux prebuild. The runtime stage copies the result and never installs a compiler. `PENGUIN_VERSION` and `PENGUIN_COMMIT` build args carry the image labels, and the commit is stamped into the build the way a release stamps it.+- The base is Ubuntu 24.04 plus the official nodejs.org runtime, pinned to the version `release.yml` bundles into the release tarballs and verified against that release's `SHASUMS256.txt`. `git`, `curl` and `ca-certificates` are the only other packages, for the commands an agent runs.+- The container starts as root solely to take ownership of the top level of the data root, then `setpriv` drops to `penguin` (uid/gid 1000): a bind mount needs no preparation on the host, and nothing but the entrypoint runs privileged. `tini` is PID 1, so the orphans an agent's shell commands leave behind are reaped.+- `HEALTHCHECK` probes the public `GET /api/install`.+- `.github/workflows/docker.yml` holds the build and publish steps and owns both tag policies: a push to `main`, which carries no path filter, and a `workflow_call` from `release.yml`'s `docker` job, gated the way `mirror-oss` is and checked out at the tag. Nothing installs from npm any more, so that job no longer waits on `publish-npm`. A pull request touching the `Dockerfile`, `docker/` or that workflow runs the same file as an amd64 smoke build of the pull request's own source, which starts the container and checks readiness, sign-in, the healthcheck, the process user, a graceful stop and a restart onto the same data root.+- `docker/compose.yaml` is the copy-and-run deployment. A new [Docker quickstart](https://penguin.ooo/docs/quickstart-docker) documents the first sign-in through the log, upgrading by pulling a new tag (in-container self-update is not supported), reverse proxies, Workspace previews and the forgotten-password rescue; the README install sections and the Quickstart route tables gained the route in both languages.diff --git a/changelog/unreleased/2026-09-04-official-docker-image.zh.md b/changelog/unreleased/2026-09-04-official-docker-image.zh.mdnew file mode 100644index 00000000..8349aed9--- /dev/null+++ b/changelog/unreleased/2026-09-04-official-docker-image.zh.md@@ -0,0 +1,19 @@+# 官方 Docker 镜像,由源码构建++- **Date:** 2026-09-04+- **Type:** feature+- **Scope:** `ci`, `tooling`, `docs`+- **PR:** [#609](https://github.com/Prism-Shadow/penguin-harness/pull/609)++[English](2026-09-04-official-docker-image.md)++PenguinHarness 新增官方容器镜像 `hiyouga/penguinharness`(Docker Hub),由本仓库源码构建,提供 `linux/amd64` 与 `linux/arm64` 两个架构。每次 push `main` 都把该 commit 发布为 `latest`,并附一个不可变的孪生 tag `main-<sha7>`;发布版则推出 `X.Y.Z`、`X.Y`,以及在该 tag 仍是 GitHub 当前 latest Release 时的 `stable`。它在 `0.0.0.0:7364` 上运行 `penguin server`,数据目录落在 `/data` 卷上,因此一次部署就是一个容器加一个卷。compose 文件与文档中的每一条 `docker run` 都把端口发布在宿主机回环上(`127.0.0.1:7364:7364`),新部署因此只在运行 Docker 的那台机器上可达;对外开放是一个明确的选择,与反向代理一节并列记录。++## 细节++- 镜像走的是发布包 CLI 的同一套装配流程:安装 workspace,构建服务端所需的包,`pnpm deploy` 出一份生产依赖树到 `/opt/penguin/lib`,再把构建好的前端产物放到旁边的 `/opt/penguin/web`。分层按「在哪台机器上跑」切分——workspace 的构建固定在构建平台上,因为 TypeScript 与 Vite 的产物与平台无关;目标平台层只重新编译 `node-pty`,它是这棵依赖树里唯一的原生依赖,且不提供 Linux 预编译产物。运行层只把结果拷进来,从不安装编译器。镜像标签取自 `PENGUIN_VERSION` 与 `PENGUIN_COMMIT` 两个构建参数,commit 按发布流程同样的方式打进构建产物。+- 基础镜像为 Ubuntu 24.04 加官方 nodejs.org 运行时,版本与 `release.yml` 打进发布包的一致,并对照该版本的 `SHASUMS256.txt` 校验。此外只装 `git`、`curl` 与 `ca-certificates`,供 Agent 执行命令之用。+- 容器以 root 启动,仅为接管数据目录顶层的属主,随即由 `setpriv` 降权到 `penguin`(uid/gid 1000):宿主机上的 bind mount 无需事先准备,且除入口脚本外没有任何东西以特权运行。PID 1 是 `tini`,Agent 的 shell 命令留下的孤儿进程因此得以回收。+- `HEALTHCHECK` 打的是公开的 `GET /api/install`。+- 构建与发布步骤放在 `.github/workflows/docker.yml`,两套 tag 策略都由它掌管:一条是 push `main`(不设路径过滤),另一条是 `release.yml` 的 `docker` job 经 `workflow_call` 调用,门槛与 `mirror-oss` 一致,并检出到该 tag。既然不再从 npm 安装任何东西,该 job 也不再等待 `publish-npm`。改动 `Dockerfile`、`docker/` 或该 workflow 的 pull request 会以同一个文件跑一次 amd64 冒烟构建,构建的正是该 pull request 自己的源码:启动容器并检查就绪、登录、健康检查、进程用户、优雅停机,以及在同一数据目录上重启。+- `docker/compose.yaml` 是可直接复制运行的部署示例。新增的 [Docker 快速开始](https://penguin.ooo/docs/quickstart-docker)记录了从日志完成首次登录、以换 tag 的方式升级(容器内不支持自更新)、反向代理、Workspace 预览与忘记密码的救援路径;README 的安装小节与快速开始的路线表也在两种语言下补上了这条路线。diff --git a/docker/compose.yaml b/docker/compose.yamlnew file mode 100644index 00000000..b1c131c9--- /dev/null+++ b/docker/compose.yaml@@ -0,0 +1,31 @@+# Minimal PenguinHarness deployment. `docker compose up -d`, then read the first-login+# link out of `docker compose logs penguin`.+#+# See https://penguin.ooo/docs/quickstart-docker for the first sign-in, upgrades, running+# behind a reverse proxy, and the rescue path for a forgotten admin password.+services:+ penguin:+ image: hiyouga/penguinharness:latest+ restart: unless-stopped+ ports:+ # On the host's loopback: reachable only from the machine running Docker.+ # To open it to a network, publish on all interfaces instead: "7364:7364".+ - "127.0.0.1:7364:7364"+ volumes:+ - penguin-data:/data+ # Shutting down interrupts running Tasks and waits for them to wrap up, which can take+ # a few seconds longer than Docker's 10s default.+ stop_grace_period: 30s+ # environment:+ # # Pins the built-in admin's password INSTEAD of printing a first-login link. It+ # # applies only on the very first boot, while no user exists, and must be at least+ # # 8 characters. Adding it to an already-claimed data root does nothing.+ # PENGUIN_SEED_ADMIN_PASSWORD: "choose-something-long"+ # # Behind a reverse proxy that terminates TLS and sets or strips x-forwarded-proto+ # # itself, so session cookies are marked Secure.+ # PENGUIN_TRUST_PROXY: "1"+ # # Disables the server's only outbound non-model request, the new-release check.+ # PENGUIN_UPDATE_CHECK: "off"++volumes:+ penguin-data:diff --git a/docker/entrypoint.sh b/docker/entrypoint.shnew file mode 100755index 00000000..4847eb7d--- /dev/null+++ b/docker/entrypoint.sh@@ -0,0 +1,28 @@+#!/bin/sh+# Container entrypoint: make the data root writable by the runtime user, then drop to it.+#+# The container starts as root purely so a bind mount from the host does not have to be+# chowned on the host first. Only the TOP LEVEL of the data root is touched: a root that+# has accumulated a year of Traces must not be walked on every boot, and a recursive chown+# would rewrite files a host user deliberately owns.+#+# Running the container with `--user` (compose: `user:`) skips all of this — the script is+# not root, so it just execs the command and the caller owns the mount.+set -eu++data_root="${PENGUIN_HOME:-/data}"++if [ "$(id -u)" -eq 0 ]; then+ mkdir -p "$data_root"+ # A host directory already carrying uid 1000 is left exactly as it is, which also lets+ # the container start on a mount that refuses chown altogether (some network filesystems).+ if [ "$(stat -c %u "$data_root")" != "1000" ]; then+ chown 1000:1000 "$data_root"+ fi+ # setpriv execs in place, so the server keeps tini's direct child slot and SIGTERM+ # reaches it without a relay. --init-groups replaces root's supplementary groups with+ # the ones /etc/group gives uid 1000.+ exec setpriv --reuid=1000 --regid=1000 --init-groups -- "$@"+fi++exec "$@"diff --git a/packages/docs/content/introduction.en.md b/packages/docs/content/introduction.en.mdindex 2add6baa..54d7aa7a 100644--- a/packages/docs/content/introduction.en.md+++ b/packages/docs/content/introduction.en.md@@ -45,5 +45,5 @@ The unified message protocol is called **OmniMessage** in technical writing (mar## Next steps-- Follow the [Quickstart](/quickstart): install PenguinHarness by whichever of the three routes fits you — desktop app, CLI, or SDK — and run your first Task.+- Follow the [Quickstart](/quickstart): install PenguinHarness by whichever route fits you — desktop app, CLI, Docker, or SDK — and run your first Task.- Start the design docs at the [Architecture](/architecture) overview to see how the pieces fit together.diff --git a/packages/docs/content/introduction.zh.md b/packages/docs/content/introduction.zh.mdindex 592f8618..6768c402 100644--- a/packages/docs/content/introduction.zh.md+++ b/packages/docs/content/introduction.zh.md@@ -45,5 +45,5 @@ PenguinHarness 的能力围绕三个递进的概念展开——消息协议、SD## 下一步-- 跟随[快速开始](/quickstart):桌面端、命令行、SDK 三条路线任选其一装好 PenguinHarness,跑通第一个 Task。+- 跟随[快速开始](/quickstart):桌面端、命令行、Docker、SDK 任选一条路线装好 PenguinHarness,跑通第一个 Task。- 从[架构总览](/architecture)进入设计文档,理解各组件如何协作。diff --git a/packages/docs/content/quickstart-docker.en.md b/packages/docs/content/quickstart-docker.en.mdnew file mode 100644index 00000000..67be7897--- /dev/null+++ b/packages/docs/content/quickstart-docker.en.md@@ -0,0 +1,159 @@+---+title: Docker+description: Run the official PenguinHarness image — one container, one volume, the full Web App on port 7364.+---++The official image runs the same server `penguin server` starts, with the Web App inside it. One container and one volume are the whole deployment, which makes it the shortest route onto a machine that is not your laptop.++```+hiyouga/penguinharness+```++`latest` follows `main` — every push rebuilds it, and `main-<sha7>` names that same image immutably. `stable` is the newest release; `X.Y.Z` and `X.Y` pin one. Every tag is built from this repository's source at that commit, and each is a multi-platform manifest covering `linux/amd64` and `linux/arm64`, so the same reference serves an x86 VPS and an arm64 one alike. The examples below use `latest`; a deployment that should move only when a version ships wants `stable` instead.++## Run it++```yaml tab="compose.yaml"+services:+ penguin:+ image: hiyouga/penguinharness:latest+ restart: unless-stopped+ ports:+ - "127.0.0.1:7364:7364"+ volumes:+ - penguin-data:/data+ stop_grace_period: 30s++volumes:+ penguin-data:+```++```bash tab="docker run"+docker volume create penguin-data+docker run -d --name penguin \+ -p 127.0.0.1:7364:7364 \+ -v penguin-data:/data \+ --restart unless-stopped \+ hiyouga/penguinharness:latest+```++With the compose file saved next to you, `docker compose up -d` starts it. Either way the Web App is then at `http://localhost:7364`, on the machine running Docker.++Both examples publish the port on that machine's loopback, so a fresh deployment is reachable from nowhere else — from another machine, forward it over ssh (`ssh -L 7364:127.0.0.1:7364 <host>`). Exposing it to a network is a deliberate step: publish on all interfaces instead (`-p 7364:7364` or `-p 0.0.0.0:7364:7364`, `"7364:7364"` in compose), preferably behind a reverse proxy that terminates TLS — see [Behind a reverse proxy](#behind-a-reverse-proxy). The container itself always listens on `0.0.0.0` inside its own network namespace, which is what makes a publish work at all; the address in `-p` is the host's half of it.++## First sign-in++A fresh data root has no password. The server prints a sign-in link in a framed notice on every start until one is set — read it out of the container's log:++```bash+docker compose logs penguin # or: docker logs penguin+```++```++----------------------------------------------------------------------------------------------++| This server has no admin password yet. Open this link to claim it: |+| |+| http://localhost:7364/api/auth/claim?token=GSiEDYM8MbsrqtMj7ofq7klUyXcfQNwt3oUriUHiBI8 |+| |+| The link lasts 30 days or until a password is set; restarting prints a fresh one. |++----------------------------------------------------------------------------------------------++```++The `localhost` in that URL is the server's own view of itself. With the loopback publish above it is also yours, so open the link as it stands on the machine running Docker; if you published the container to a network, replace `localhost` with the host you reach it on. Either way keep the whole `?token=...`. You land signed in as `admin` and set a password. The link is re-minted on every start, so a restart invalidates the one you were looking at and prints a fresh one.++If reading a link out of a log does not suit your setup, pin the password instead — but do it **before the first start**:++```yaml+environment:+ PENGUIN_SEED_ADMIN_PASSWORD: "choose-something-long"+```++It seeds the built-in `admin` with that password (8 characters minimum) and suppresses the notice. It applies **only while no user exists**, which is the first boot of an empty data root: adding it to a data root that has already been claimed changes nothing, and neither does changing it later.++## Configure a model++PenguinHarness ships with no model credentials. Use the **Models** page in the Web App, or the CLI inside the container:++```bash+docker compose exec -u penguin penguin \+ penguin config model add --provider deepseek --model-id deepseek-v4-flash-vision-exp --api-key sk-... --set-default+```++The `-u penguin` matters: `docker exec` runs as root by default, and files it writes into `/data` would then be owned by root while the server runs as uid 1000. See [Models & Providers](/models) for the built-in groups.++## What is in the image++| | |+| --- | --- |+| Base | Ubuntu 24.04 with the official Node.js runtime, matching the version the release tarballs bundle |+| Command | `penguin server`, on `0.0.0.0:7364` |+| Data root | `/data`, declared as a volume — model configuration, Sessions, Traces and the SQLite database |+| Process user | `penguin`, uid/gid 1000; the entrypoint starts as root only to take ownership of the data root, then drops |+| Healthcheck | `GET /api/install` every 30s |+| Tools | `git`, `curl` and the standard Ubuntu userland, for the commands an agent runs |++Everything the agent's `exec_command` runs happens **inside this container**, on its filesystem and its network. That is the isolation boundary and also the limit: an agent can reach whatever the container can reach, and nothing else. Give it a Workspace by mounting a directory (`-v /srv/project:/srv/project`), and remember the mount needs to be writable by uid 1000.++The image carries no compiler and no language runtimes beyond Node. `apt-get install` inside the container works for a one-off, but it is lost on the next `docker pull`; for anything you depend on, build a derived image:++```dockerfile+FROM hiyouga/penguinharness:latest+USER root+RUN apt-get update && apt-get install -y --no-install-recommends python3 ripgrep \+ && rm -rf /var/lib/apt/lists/*+USER penguin+```++Note that the runtime image deliberately has no C/C++ toolchain: it is a stage the build throws away.++## Environment++The full list is in the [Configuration Reference](/configuration); these are the ones a container deployment touches.++| Variable | In this image |+| --- | --- |+| `PENGUIN_HOME` | `/data` — change it only if you also move the volume |+| `HOST` | `0.0.0.0` — the container's own namespace; `-p` decides the host side, and the examples keep it on loopback |+| `PORT` | `7364`; changing it moves the healthcheck with it |+| `PENGUIN_SEED_ADMIN_PASSWORD` | Pins the initial admin password, first boot only (see above) |+| `PENGUIN_TRUST_PROXY` | Set to `1` behind a TLS-terminating reverse proxy, so session cookies are marked `Secure` |+| `PENGUIN_PREVIEW_ORIGIN` | A second hostname routed to the same container, for Workspace HTML previews |+| `PENGUIN_UPDATE_CHECK` | `off` disables the release check — the server's only outbound non-model request |++### Behind a reverse proxy++Publish the container on loopback, terminate TLS in front of it, and set `PENGUIN_TRUST_PROXY=1`. The proxy must set or strip `x-forwarded-proto` itself; the header is caller-supplied, which is exactly why the server ignores it until you say otherwise. Leaving it unset on an HTTPS deployment issues session cookies without the `Secure` flag.++### Workspace previews++Previews of HTML a Task produces are served from a separate origin when there is one. On a non-loopback bind there is no loopback counterpart to derive, so they fall back to a same-origin sandbox where cookies, `localStorage` and third-party embeds do not work. Point `PENGUIN_PREVIEW_ORIGIN` at a second hostname routed to the same container to get the isolated version back — it must differ by hostname, not just port.++## Upgrading++Pull a newer tag and recreate the container. The data root is on the volume and carries over:++```bash+docker compose pull && docker compose up -d+```++In-container self-update is **not** the path. The Web App's update button reports the release as unsupported here — the server has no re-runnable CLI entry to hand an update to — and the restart control reports that nothing supervises it. `penguin update` run inside the container would install into a filesystem the next recreate throws away, and it fails anyway: the runtime image carries no compiler, and `node-pty` has no Linux prebuild to fall back on.++Stopping is graceful: `SIGTERM` interrupts running Tasks, waits for them to wrap up, then closes the database. An idle server stops in well under a second; a busy one can take several, which is why the compose example raises Docker's 10-second grace period.++## Rescue: a forgotten admin password++The data root is the authorization — someone who can run this command already has the database. The server has to be stopped first, because a data root only ever has one writer:++```bash+docker compose stop penguin+docker compose run --rm penguin penguin server reset-admin-password+docker compose start penguin+```++The account returns to the unclaimed state with its sessions revoked, so sign in again through the first-login link in the log, exactly as on a fresh server.++## Next steps++- [Web App Guide](/web-app): use PenguinHarness from the browser.+- [Security Model](/security): who can do what, and on the strength of which proof.+- [Configuration Reference](/configuration): every environment variable and config field.diff --git a/packages/docs/content/quickstart-docker.zh.md b/packages/docs/content/quickstart-docker.zh.mdnew file mode 100644index 00000000..e8933a4e--- /dev/null+++ b/packages/docs/content/quickstart-docker.zh.md@@ -0,0 +1,159 @@+---+title: Docker+description: 运行官方 PenguinHarness 镜像——一个容器、一个卷,7364 端口上是完整的 Web 应用。+---++官方镜像跑的就是 `penguin server` 启动的那个服务端,Web 应用在里面。整套部署只有一个容器和一个卷,因此它是把 PenguinHarness 装到自己电脑以外的机器上最短的一条路。++```+hiyouga/penguinharness+```++`latest` 跟随 `main`——每次 push 都重新构建它,`main-<sha7>` 则是同一个镜像的不可变名字。`stable` 是最新的发布版;`X.Y.Z` 与 `X.Y` 用于钉住某个发布版。每个 tag 都由本仓库该 commit 的源码构建,也都是覆盖 `linux/amd64` 与 `linux/arm64` 的多平台 manifest,同一个引用在 x86 VPS 与 arm64 机器上通用。下面的示例用 `latest`;只希望随发布版移动的部署应改用 `stable`。++## 跑起来++```yaml tab="compose.yaml"+services:+ penguin:+ image: hiyouga/penguinharness:latest+ restart: unless-stopped+ ports:+ - "127.0.0.1:7364:7364"+ volumes:+ - penguin-data:/data+ stop_grace_period: 30s++volumes:+ penguin-data:+```++```bash tab="docker run"+docker volume create penguin-data+docker run -d --name penguin \+ -p 127.0.0.1:7364:7364 \+ -v penguin-data:/data \+ --restart unless-stopped \+ hiyouga/penguinharness:latest+```++把 compose 文件放在当前目录,`docker compose up -d` 即启动。两种方式启动后,Web 应用都在运行 Docker 的那台机器的 `http://localhost:7364`。++两个示例都把端口发布在该机器的回环上,因此新部署在别处一概不可达——要从另一台机器访问,用 ssh 转发(`ssh -L 7364:127.0.0.1:7364 <host>`)。对外开放是一个明确的动作:改为发布到所有接口(`-p 7364:7364` 或 `-p 0.0.0.0:7364:7364`,compose 写 `"7364:7364"`),并尽量置于终结 TLS 的反向代理之后——见[反向代理之后](#反向代理之后)。容器自身始终在自己的网络命名空间里监听 `0.0.0.0`,这正是端口发布得以成立的前提;`-p` 里的地址是宿主机这一侧。++## 首次登录++新数据目录没有密码。在密码被设置之前,服务端每次启动都会以边框提示打印一条登录链接——从容器日志里读它:++```bash+docker compose logs penguin # 或:docker logs penguin+```++```++----------------------------------------------------------------------------------------------++| This server has no admin password yet. Open this link to claim it: |+| |+| http://localhost:7364/api/auth/claim?token=GSiEDYM8MbsrqtMj7ofq7klUyXcfQNwt3oUriUHiBI8 |+| |+| The link lasts 30 days or until a password is set; restarting prints a fresh one. |++----------------------------------------------------------------------------------------------++```++那条 URL 里的 `localhost` 是服务端对自己的称呼。按上面的回环发布,它同时也是你的,因此在运行 Docker 的那台机器上原样打开即可;若你已把容器发布到网络上,则把 `localhost` 换成你实际访问它所用的主机名或 IP。两种情况都要保留整段 `?token=...`。落地即已登录为 `admin`,随即设置密码。链接在每次启动时重新铸造,所以一次重启就会作废你正看着的那条,并打印一条新的。++如果从日志里读链接不适合你的场景,也可以直接把密码钉死——但必须**在首次启动之前**:++```yaml+environment:+ PENGUIN_SEED_ADMIN_PASSWORD: "choose-something-long"+```++它以该密码(至少 8 位)种下内置管理员 `admin`,并不再打印提示。它**仅在尚无任何用户时生效**,也就是空数据目录的第一次启动:加到已被认领的数据目录上不会有任何效果,事后改动同样无效。++## 配置模型++PenguinHarness 不内置任何模型凭据。可以用 Web 应用的**模型**页,也可以用容器里的 CLI:++```bash+docker compose exec -u penguin penguin \+ penguin config model add --provider deepseek --model-id deepseek-v4-flash-vision-exp --api-key sk-... --set-default+```++`-u penguin` 是必要的:`docker exec` 默认以 root 执行,它写进 `/data` 的文件会归 root 所有,而服务端是以 uid 1000 运行的。内置分组见[模型与 Provider](/models)。++## 镜像里有什么++| | |+| --- | --- |+| 基础镜像 | Ubuntu 24.04,加官方 Node.js 运行时,版本与发布包内嵌的一致 |+| 启动命令 | `penguin server`,监听 `0.0.0.0:7364` |+| 数据目录 | `/data`,声明为卷——模型配置、会话、Trace 与 SQLite 数据库都在其中 |+| 运行用户 | `penguin`,uid/gid 1000;入口脚本仅为接管数据目录的属主而以 root 启动,随即降权 |+| 健康检查 | 每 30 秒一次 `GET /api/install` |+| 工具 | `git`、`curl` 与 Ubuntu 标准用户态,供 Agent 执行命令 |++Agent 的 `exec_command` 跑的一切都发生在**这个容器内部**,用的是它的文件系统与它的网络。这既是隔离边界,也是能力边界:容器能访问什么,Agent 就能访问什么,仅此而已。要给它一个 Workspace 就挂一个目录进来(`-v /srv/project:/srv/project`),注意该挂载需要对 uid 1000 可写。++镜像不带编译器,Node 之外也不带其他语言运行时。临时用一下,在容器里 `apt-get install` 是可行的,但下一次 `docker pull` 就没了;凡是要长期依赖的,构建一个派生镜像:++```dockerfile+FROM hiyouga/penguinharness:latest+USER root+RUN apt-get update && apt-get install -y --no-install-recommends python3 ripgrep \+ && rm -rf /var/lib/apt/lists/*+USER penguin+```++注意运行镜像刻意不含 C/C++ 工具链:那是构建阶段用完即丢的一层。++## 环境变量++完整清单见[配置参考](/configuration),这里只列容器部署会用到的。++| 变量 | 在本镜像中 |+| --- | --- |+| `PENGUIN_HOME` | `/data`——除非同时改卷的挂载点,否则不要改 |+| `HOST` | `0.0.0.0`——容器自己的命名空间;宿主机这一侧由 `-p` 决定,示例把它留在回环上 |+| `PORT` | `7364`;改它会连带把健康检查一起移过去 |+| `PENGUIN_SEED_ADMIN_PASSWORD` | 钉死初始管理员密码,仅首次启动生效(见上文) |+| `PENGUIN_TRUST_PROXY` | 在终结 TLS 的反向代理之后设为 `1`,使会话 Cookie 带上 `Secure` |+| `PENGUIN_PREVIEW_ORIGIN` | 指向同一容器的第二个主机名,用于 Workspace 的 HTML 预览 |+| `PENGUIN_UPDATE_CHECK` | `off` 关闭新版本检查——服务端唯一一个非模型的出网请求 |++### 反向代理之后++把容器发布在回环上,在它前面终结 TLS,并设 `PENGUIN_TRUST_PROXY=1`。代理必须自己设置或剥除 `x-forwarded-proto`;该头由调用方提供,这正是服务端在你明说之前不予采信的原因。HTTPS 部署下不设它,签发的会话 Cookie 就不带 `Secure` 标记。++### Workspace 预览++Task 产出的 HTML,在有独立来源时会从另一个来源提供。非回环绑定下没有可推导的回环对应地址,预览会退化为同源沙箱,此时 Cookie、`localStorage` 与第三方内嵌都不可用。把 `PENGUIN_PREVIEW_ORIGIN` 指向路由到同一容器的第二个主机名即可恢复隔离版本——它必须在**主机名**上不同,仅端口不同不算。++## 升级++拉一个新 tag 并重建容器。数据目录在卷上,原样保留:++```bash+docker compose pull && docker compose up -d+```++容器内的自更新**不是**升级路径。Web 应用的升级按钮在这里会报「不支持」——服务端没有可再次运行的 CLI 入口,无从把升级交出去——重启入口也会报没有托管进程。在容器里执行 `penguin update` 则会把新包装进下次重建即丢弃的文件系统,而且无论如何都会失败:运行镜像不含编译器,`node-pty` 也没有可回退的 Linux 预编译产物。++停止是优雅的:`SIGTERM` 会打断运行中的 Task,等它们收尾,再关闭数据库。空闲的服务端远不到一秒就停住,繁忙的可能要几秒——compose 示例把 Docker 默认的 10 秒宽限期调高,正是为此。++## 救援:忘记管理员密码++授权模型就是数据目录本身——能执行这条命令的人本就持有那个数据库。必须先停掉服务端,因为一个数据目录同一时刻只有一个写者:++```bash+docker compose stop penguin+docker compose run --rm penguin penguin server reset-admin-password+docker compose start penguin+```++账号回到未认领状态并清空全部会话,之后照新服务器的流程,从日志里的首次登录链接重新登录。++## 下一步++- [Web 应用指南](/web-app):在浏览器里使用 PenguinHarness。+- [安全模型](/security):谁能做什么,凭什么。+- [配置参考](/configuration):全部环境变量与配置字段。diff --git a/packages/docs/content/quickstart-sdk.en.md b/packages/docs/content/quickstart-sdk.en.mdindex 9d1c6b79..d966ac33 100644--- a/packages/docs/content/quickstart-sdk.en.md+++ b/packages/docs/content/quickstart-sdk.en.md@@ -15,7 +15,7 @@ npm install @prismshadow/penguin-core## Configure a model-The SDK reads the same data root as the other two routes, `~/.penguin/data`, so a model configured in the [desktop app](/quickstart-desktop) or the [CLI](/quickstart-cli) is immediately usable — there is nothing to configure twice.+The SDK reads the same data root as the desktop app and the CLI, `~/.penguin/data`, so a model configured in the [desktop app](/quickstart-desktop) or the [CLI](/quickstart-cli) is immediately usable — there is nothing to configure twice.If this machine has no model configured yet, the shortest path is to install the CLI and do it once:diff --git a/packages/docs/content/quickstart-sdk.zh.md b/packages/docs/content/quickstart-sdk.zh.mdindex a5a87144..4c952db0 100644--- a/packages/docs/content/quickstart-sdk.zh.md+++ b/packages/docs/content/quickstart-sdk.zh.md@@ -15,7 +15,7 @@ npm install @prismshadow/penguin-core## 配置模型-SDK 与其他两条路线读同一个数据目录 `~/.penguin/data`,所以在[桌面端应用](/quickstart-desktop)或 [CLI](/quickstart-cli) 里配好的模型,SDK 直接可用,无需重复配置。+SDK 与桌面端应用、CLI 读同一个数据目录 `~/.penguin/data`,所以在[桌面端应用](/quickstart-desktop)或 [CLI](/quickstart-cli) 里配好的模型,SDK 直接可用,无需重复配置。如果这台机器还没配过模型,最省事的方式是装上 CLI 配一次:diff --git a/packages/docs/content/quickstart.en.md b/packages/docs/content/quickstart.en.mdindex f49ffa1d..fca6c304 100644--- a/packages/docs/content/quickstart.en.md+++ b/packages/docs/content/quickstart.en.md@@ -3,19 +3,20 @@ title: Quickstartdescription: Three routes — desktop app, CLI, or SDK — pick one to install PenguinHarness and run your first Task.----PenguinHarness has three ways in. They run the same engine; they differ only in how you meet it. Pick the one that fits you — each route's page carries you all the way to a first Task:+PenguinHarness has four ways in. They run the same engine; they differ only in how you meet it. Pick the one that fits you — each route's page carries you all the way to a first Task:| Route | Best for | Terminal needed? || --- | --- | --- || [Desktop app](/quickstart-desktop) | Using PenguinHarness as a product, straight away | No — and it installs the `penguin` command for you || [CLI and Web App](/quickstart-cli) | Servers and remote machines, or wanting the `penguin` command | Once, to install |+| [Docker](/quickstart-docker) | A server you deploy rather than install — one container, one volume | Once, to start it || [SDK](/quickstart-sdk) | Embedding the engine in your own TypeScript program | Yes |If you are unsure, take the [desktop app](/quickstart-desktop): it has the fewest steps, and moving to another route later costs you nothing. The macOS and Windows installers are signed, so only a downloaded Linux AppImage needs anything before the first launch — that page carries it.-## What all three share+## What they all share-- **One data root**: `~/.penguin/data` (`%USERPROFILE%\.penguin\data` on Windows). Agents, model configuration and past Sessions are common to all three routes, so they can be mixed freely — a model configured in the desktop app is immediately usable from the CLI and the SDK.+- **One data root**: `~/.penguin/data` (`%USERPROFILE%\.penguin\data` on Windows; `/data` inside the container). Agents, model configuration and past Sessions live there, so the routes that share a machine can be mixed freely — a model configured in the desktop app is immediately usable from the CLI and the SDK.- **One server at a time**: a data root only ever runs one server process. If a CLI-started instance is already up from `penguin web`, the desktop app attaches to it instead of starting a second one.- **One interface**: the desktop app and `penguin web` open the same Web App; the former just embeds the server and skips the login.@@ -29,4 +30,5 @@ A model is always referenced as a `(provider, model_id)` pair — the Provider i- [Desktop app](/quickstart-desktop): a double-click install that opens already signed in.- [CLI and Web App](/quickstart-cli): one line installs `penguin`; includes the full installation reference.+- [Docker](/quickstart-docker): the official image, for a server you reach over the network.- [SDK](/quickstart-sdk): create Agents and Sessions from your own program.diff --git a/packages/docs/content/quickstart.zh.md b/packages/docs/content/quickstart.zh.mdindex 3744dd68..4812d3b0 100644--- a/packages/docs/content/quickstart.zh.md+++ b/packages/docs/content/quickstart.zh.md@@ -3,19 +3,20 @@ title: 快速开始description: 桌面端、命令行、SDK 三条路线,挑一条装好 PenguinHarness 并跑通第一个 Task。----PenguinHarness 有三条入口,背后是同一个引擎,区别只在你以什么方式接触它。先挑一条适合自己的,各自的页面会把你一路带到第一个 Task:+PenguinHarness 有四条入口,背后是同一个引擎,区别只在你以什么方式接触它。先挑一条适合自己的,各自的页面会把你一路带到第一个 Task:| 路线 | 适合 | 需要用终端吗 || --- | --- | --- || [桌面端应用](/quickstart-desktop) | 想直接把 PenguinHarness 当成一个应用来用 | 不需要——而且它会替你装好 `penguin` 命令 || [命令行与 Web 应用](/quickstart-cli) | 装到服务器或远程机器,或想要 `penguin` 命令 | 安装时用一次 |+| [Docker](/quickstart-docker) | 部署而非安装——一个容器、一个卷 | 启动时用一次 || [SDK](/quickstart-sdk) | 把引擎嵌进自己的 TypeScript 程序 | 需要 |拿不准就选[桌面端应用](/quickstart-desktop):它步骤最少,而且换到另一条路线不用重来。macOS 与 Windows 的安装包均已签名,只有下载来的 Linux AppImage 在首次启动前需要一步操作,那一页里写了。-## 三条路线共用什么+## 各条路线共用什么-- **同一个数据目录**:`~/.penguin/data`(Windows 为 `%USERPROFILE%\.penguin\data`)。Agent、模型配置与历史会话互通,所以三条路线可以随时混用——桌面端配好的模型,CLI 与 SDK 立刻就能用。+- **同一个数据目录**:`~/.penguin/data`(Windows 为 `%USERPROFILE%\.penguin\data`;容器内为 `/data`)。Agent、模型配置与历史会话都在其中,因此同机的几条路线可以随时混用——桌面端配好的模型,CLI 与 SDK 立刻就能用。- **同一时刻只有一个服务端**:一个数据目录只跑一个服务端进程。命令行已经用 `penguin web` 启动过实例时,桌面端应用会直接接入它,而不是再起一个。- **同一套界面**:桌面端应用与 `penguin web` 打开的是同一个 Web App,只是前者内嵌了服务端、免去登录。@@ -29,4 +30,5 @@ PenguinHarness 不内置任何模型凭据,跑第一个 Task 之前必须先- [桌面端应用](/quickstart-desktop):双击安装,打开即已登录。- [命令行与 Web 应用](/quickstart-cli):一行安装 `penguin`,含完整的安装参考。+- [Docker](/quickstart-docker):官方镜像,用于经网络访问的服务端。- [SDK](/quickstart-sdk):在自己的程序里创建 Agent 与 Session。diff --git a/packages/docs/content/security.en.md b/packages/docs/content/security.en.mdindex dfc77f6a..d9891e64 100644--- a/packages/docs/content/security.en.md+++ b/packages/docs/content/security.en.md@@ -43,6 +43,8 @@ Open it, land signed in, set a password. The link is not one-shot — a mail cli- The value it is compared against lives **in memory and is re-minted on every restart**. A link from an earlier run is refused; if you miss the notice, restart and read the new one.- A wrong token and an already-claimed server answer **identically** — a stale link cannot even reveal which of the two it is.+In a container the notice goes to the container's log (`docker logs`), and the `localhost` in the link is the server's own view of itself — with the documented loopback publish that is your view too, so open it as it stands on the machine running Docker; a container published to a network needs `localhost` replaced with the host you reach it on. Keep the token either way. `PENGUIN_SEED_ADMIN_PASSWORD` pins the password instead, but only on the first boot of an empty data root.+The session it grants carries `via: setup`. It has exactly one special allowance — setting a password without an old one, since no old one exists — and no more: in particular, none of the desktop-only routes.**Desktop.** The shell owns the server process it embeds, so its window is let in on that fact alone: the window's first navigation redeems a one-shot token minted by the shell, and lands signed in as `via: desktop`. The token dies on redemption — a leaked URL replays nothing.diff --git a/packages/docs/content/security.zh.md b/packages/docs/content/security.zh.mdindex bfdd9c28..506aed0f 100644--- a/packages/docs/content/security.zh.md+++ b/packages/docs/content/security.zh.md@@ -43,6 +43,8 @@ PenguinHarness 用真实凭据在真实机器上跑智能体,所以"谁凭什- 用来比对的那个值**只在内存里,每次重启重新铸造**。更早一次运行的链接会被拒绝;错过提示,重启再读新的即可。- 错误令牌与已认领的服务器返回**完全一致**——一条过期链接连"属于哪种情况"都无法透露。+在容器里,这条提示打在容器日志(`docker logs`)中,链接里的 `localhost` 是服务端对自己的称呼——按文档给出的回环发布,它也正是你的视角,在运行 Docker 的那台机器上原样打开即可;若容器已发布到网络上,则把 `localhost` 换成你实际访问它所用的地址。两种情况下令牌都保持不变。`PENGUIN_SEED_ADMIN_PASSWORD` 可以改为直接钉死密码,但仅在空数据目录的首次启动时生效。+它授予的会话带 `via: setup`,恰好持有一项特殊豁免——免旧密码设置密码,因为旧密码并不存在——再无其他:尤其是,不含任何桌面专属路由。**桌面。** 客户端拥有它内嵌的服务进程,它的窗口凭这一事实被放行:窗口的首次导航兑换一枚由客户端铸造的一次性令牌,落地即以 `via: desktop` 登录。令牌在兑换的瞬间死亡——泄露的 URL 无法重放。diff --git a/packages/docs/src/lib/nav.ts b/packages/docs/src/lib/nav.tsindex f70defd6..1e23760e 100644--- a/packages/docs/src/lib/nav.ts+++ b/packages/docs/src/lib/nav.ts@@ -36,7 +36,7 @@ export const DOCS_NAV: DocsSectionDef[] = [{ slug: "introduction" },{slug: "quickstart",- children: ["quickstart-desktop", "quickstart-cli", "quickstart-sdk"],+ children: ["quickstart-desktop", "quickstart-cli", "quickstart-docker", "quickstart-sdk"],},],},