Skip to content

digitalocean: App Platform deployment scaffolding (basic, no ngrok/Tailscale) - #248

Merged
FMXExpress merged 2 commits into
mainfrom
claude/do-app-platform
Jun 13, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/do-app-platform

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

Adds a minimal "just basic" DigitalOcean App Platform deployment under digitalocean/. Single pasclaw gateway web service, no s6-overlay, no ngrok / Tailscale / Spaces backup, no CHEATSHEET / AI-ASSISTED-SETUP / CLAUDE.md. Modelled on openclaw-appplatform but trimmed to the essentials.

Also extends the root .dockerignore to exclude docs/, cog/, browser/, all *.md, Delphi project files, and local env files — answering the pre-PR question "won't this unrelated stuff go in the container?".

What's in digitalocean/

File Purpose
Dockerfile Two-stage FPC build. Stage 1 (debian:bookworm + fp-compiler) clones Indy at build time and compiles. Stage 2 (bookworm-slim + libssl3 + libsqlite3 + tini) ~80 MB final image.
entrypoint.sh mkdir $PASCLAW_HOME, stamp config.template.json → config.json on first boot (never clobbers existing), exec pasclaw gateway --addr 0.0.0.0 --port $PORT.
config.template.json Defaults wired with ${VAR_NAME} markers — PR #247's substitution resolves them from env at LoadConfig time. Anthropic primary, OpenAI fallback, optional Brave web_search, optional OTel, sandbox + denylist on.
.do/app.yaml App Spec: github source → dockerfile path, basic-xxs (~$5/mo), health probe on /v1/health, SECRET-marked env vars for the gateway token + provider keys.
.env.example Documented env vars for local Makefile use.
Makefile make build / run / health / smoke targets for local Docker testing.
README.md Five-step deploy via dashboard OR doctl, cost breakdown, persistent-state caveat, security notes, deliberate-omissions list.

Deploy flow (5 steps)

  1. Fork the repo (or use yours directly).
  2. Paste digitalocean/.do/app.yaml into https://cloud.digitalocean.com/apps/new/spec (or doctl apps create --spec).
  3. Set SECRET env vars in the dashboard: PASCLAW_GATEWAY_TOKEN (openssl rand -hex 32), ANTHROPIC_API_KEY, optional OPENAI_API_KEY / PASCLAW_BRAVE_API_KEY / OTEL_EXPORTER_OTLP_ENDPOINT.
  4. Wait for the build (~5 min first time, ~3 min incremental).
  5. Hit https://your-app.ondigitalocean.app/v1/health to verify, then curl -H "Authorization: Bearer $TOKEN" /v1/chat/completions to chat.

.dockerignore (the user's concern)

Extended from the existing PR #121 baseline. Now excludes wholesale:

  • docs/ (~3,800 LOC of markdown)
  • cog/ (Replicate deployment scaffold)
  • browser/ (container2wasm wasm-build outputs)
  • samples/**/build/ (already there)
  • vendor/Indy/ (~600 MB; Dockerfile re-clones at build time)
  • **/*.md, **/*.markdown
  • Delphi project files (*.dproj, *.dpk, **/__history/, **/__recovery/)
  • Local env files (.env, .env.*, .envrc)

Belt-and-suspenders: the new digitalocean/Dockerfile uses selective COPY for every file it needs (Makefile, src/, two files from digitalocean/) so wholesale exclusion is just an upload speedup AND a guard against future Dockerfiles that do COPY .. The existing cog/ build benefits for free.

Deliberately omitted (vs. openclaw)

  • s6-overlay — single process. tini reaps zombies (shell_exec / execute_code spawn lots).
  • ngrok / Tailscale / Spaces+Restic — App Platform's public URL is enough; layer the others on top if needed.
  • Persistent volume on by default — basic-cut state is ephemeral; the README documents the one-block addition to .do/app.yaml if you want sessions / memory / KB to survive restarts.
  • GHCR variant App Spec — single .do/app.yaml building from GitHub source. When you publish a prebuilt image, add .do/app-ghcr.yaml mirroring openclaw's pattern.
  • CHEATSHEET / AI-ASSISTED-SETUP / CLAUDE.md — README covers it.

Cost

Component Approx monthly cost
basic-xxs instance (512 MB / 1 vCPU) $5
basic-xs (1 GB / 1 vCPU) — if more headroom needed $12
1 GB persistent disk (optional) ~$1
Bandwidth first 100 GB free, then ~$0.01/GB

Test plan

  • make smoke — green (no PasClaw core changes, but confirming nothing about the new files breaks the existing build).
  • Dockerfile syntax + .dockerignore reviewed against every COPY directive.
  • Local make -f digitalocean/Makefile build + run on a host with docker (no docker in the agent environment; canonical pre-deploy smoke).
  • Actual deploy to a DO account (operator validation; PR description has the step-by-step).

Scope

digitalocean/ (~570 LOC across 7 files; mostly README + comments) + 26 lines added to .dockerignore. No PasClaw core changes.


Generated by Claude Code

Single-service "just basic" deployment of `pasclaw gateway` on DO
App Platform. Modelled on openclaw-appplatform but trimmed:
  - no ngrok / Tailscale / Spaces backup / CHEATSHEET / AI-SETUP /
    CLAUDE.md
  - no s6-overlay process supervisor -- pasclaw gateway runs as PID
    1 under tini for zombie reaping
  - no GHCR variant -- single App Spec building from this repo
  - no persistent volume by default -- documented opt-in for
    operators who want sessions / memory / KB to survive restarts

Files added under digitalocean/:

  Dockerfile               Two-stage FPC build. Stage 1 (debian:bookworm)
                           clones Indy at build time + compiles. Stage 2
                           (bookworm-slim) has just libssl3 / libsqlite3
                           / ca-certificates / tini + the binary. Final
                           image ~80 MB.

  entrypoint.sh            mkdir $PASCLAW_HOME, stamp
                           config.template.json into config.json on
                           first boot (only when absent -- never
                           clobbers a mounted-in custom config), exec
                           `pasclaw gateway --addr 0.0.0.0 --port $PORT`.

  config.template.json     Defaults wired with ${VAR_NAME} markers --
                           PR #247's expansion resolves them from env at
                           LoadConfig time. Anthropic primary, OpenAI
                           fallback, optional Brave web_search, optional
                           OTel, sandbox + denylist on.

  .do/app.yaml             App Spec: github source -> dockerfile_path,
                           basic-xxs (~$5/mo), health_check on
                           /v1/health, SECRET-marked env vars for the
                           gateway token + provider keys.

  .env.example             Documented env vars for local Makefile use.
                           Never commit a populated copy.

  Makefile                 docker build / run / health / smoke targets
                           rooted at the repo root so the build context
                           picks up src/ and Makefile.

  README.md                Five-step deploy via dashboard OR doctl,
                           cost breakdown (~$5/mo basic + ~$1/mo for
                           the optional 1GB volume), persistent-state
                           caveat, security notes (gateway-token as
                           the only thing between the public internet
                           and an agent that can shell + fs_*), and
                           the deliberate-omissions list.

.dockerignore extended (existing file was minimal; PR #121 shape) to
exclude wholesale: docs/, cog/, browser/, all *.md, Delphi project
files (*.dproj/*.dpk), local env files. The vendor/Indy/ exclusion
was already there from PR #121. All scaffolds-other-than-Dockerfile
metadata excluded so a future `docker build .` over the repo doesn't
silently leak ~3,800 LOC of docs + sample binaries + 600 MB of Indy
into a container image. The user's exact concern from the
pre-PR conversation: "won't this unrelated stuff go in there?"

The .dockerignore is belt-and-suspenders -- the new Dockerfile uses
selective COPY for every file it needs (Makefile, src/, two files
from digitalocean/) so wholesale exclusion of unrelated trees is
just a build-context-upload speedup AND a guard against future
Dockerfiles that do `COPY .`. cog/ benefits too -- its existing
build now skips digitalocean/ and docs/ for free.

No PasClaw core changes. `make smoke` green. Local Docker build
not exercised here (no docker in this environment); a `make
-f digitalocean/Makefile build` on any host with docker installed
walks the build end-to-end and is the canonical pre-deploy smoke
test.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97c4edb2c4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread digitalocean/config.template.json Outdated
},

"sandbox": {
"restrict_to_workspace": true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pin the sandbox to the data workspace

When this image starts, pasclaw gateway calls ConfigureSandbox(Cfg.Sandbox, ''), and an empty sandbox.workspace falls back to the process CWD. This template enables restrict_to_workspace but does not set workspace, and the Dockerfile/entrypoint never WORKDIR/cd into $PASCLAW_HOME/workspace, so in the DigitalOcean container the boundary becomes / rather than /data/pasclaw/workspace. With the public gateway token compromised, fs/shell tools can operate anywhere the pasclaw user can access, contrary to the documented workspace-only hardening.

Useful? React with 👍 / 👎.

Comment thread digitalocean/Dockerfile Outdated
# explicit value so the binary reports something stable even though .git is
# .dockerignore'd.
ARG PASCLAW_VERSION=do-appplatform
RUN make BIN=/out/pasclaw PASCLAW_VERSION=$PASCLAW_VERSION

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Create /out before writing the binary

The build target is told to write -o/out/pasclaw, but this stage never creates /out, and the root Makefile only creates $(BUILDDIR)/lib with BUILDDIR still set to build. On a DigitalOcean/App Platform build this make invocation reaches FPC with a non-existent output directory and fails before the runtime image is produced; create /out first or build to build/pasclaw like docker/Dockerfile.

Useful? React with 👍 / 👎.

Comment thread digitalocean/Dockerfile Outdated
# explicit value so the binary reports something stable even though .git is
# .dockerignore'd.
ARG PASCLAW_VERSION=do-appplatform
RUN make BIN=/out/pasclaw PASCLAW_VERSION=$PASCLAW_VERSION

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pass the Bookworm lazutils path to make

For the debian:bookworm builder, lazarus-src installs lazutils under /usr/lib/lazarus/2.2.6/...; the root Makefile defaults LAZUTILS_DIR to /usr/lib/lazarus/3.0/components/lazutils. The existing container build already overrides this, and without the same override here the Bookworm App Platform build cannot resolve the Masks unit used by PasClaw.Tools.FS.

Useful? React with 👍 / 👎.

Comment thread digitalocean/Dockerfile
Comment on lines +70 to +72
RUN apt-get update && apt-get install -y --no-install-recommends \
libsqlite3-0 \
libssl3 \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bundle Indy's OpenSSL runtime instead of libssl3

This runtime image only installs Debian's OpenSSL 3 package. The repository's existing docker/Dockerfile bundles libssl.so.1.0.2/libcrypto.so.1.0.2 because the vendored Indy TLS path dlopens libssl.so and bails on OpenSSL 1.1/3; libssl3 provides libssl.so.3, not the 1.0 names. If the DigitalOcean image does build and starts, HTTPS provider calls to Anthropic/OpenAI will fail with no loadable TLS backend.

Useful? React with 👍 / 👎.

1. config.template.json: pin sandbox.workspace
   Without an explicit workspace value the boundary defaults to the
   process cwd at startup, which is whatever PASCLAW_HOME's parent
   happens to be -- not the /data/pasclaw/workspace tree the
   entrypoint creates. Set it explicitly so the sandbox guards the
   right tree even if a future entrypoint edit changes cwd or
   PASCLAW_HOME's mkdir behaviour.

2. Dockerfile build stage: mkdir -p /out
   `make BIN=/out/pasclaw` writes the link output to /out/pasclaw,
   but make doesn't create /out itself. The build was failing
   before the runtime stage ever got to COPY --from=builder. Add
   the mkdir in front of make and the build proceeds.

3. Dockerfile build stage: pin LAZUTILS_DIR for Bookworm
   Pasclaw's Makefile autodetect targets
   /usr/lib/lazarus/3.0/components/lazutils (the Lazarus 3.x /
   Trixie layout). Debian Bookworm ships lazarus-src 2.2.6 under
   /usr/share/lazarus/2.2.6/components/lazutils -- different prefix
   AND different version. Resolution of the Masks unit
   (PasClaw.Tools.FS's `include` glob) failed before this. Pass
   LAZUTILS_DIR=/usr/share/lazarus/2.2.6/components/lazutils
   explicitly to make.

4. Dockerfile runtime stage: ship libssl1.0.2 instead of libssl3
   Vendored Indy's IdSSLOpenSSLHeaders.SSLDLLVers array only dynamic-
   loads libssl.so.10 / libssl.so.1.0.x. It does NOT know about
   libssl.so.1.1 (Bullseye) or libssl.so.3 (Bookworm). Without
   libssl1.0 in the runtime image every outbound HTTPS call --
   provider chats, MCP, OTel exports, web_fetch -- would fail
   immediately with EIdOSSLCouldNotLoadSSLLibrary. Pull the last
   Debian-published libssl1.0.2 .deb from snapshot.debian.org's
   long-term archive (URL pinned for repeatability) and dpkg -i it
   alongside libssl3. README "Known issues" section documents the
   fragility and the long-term fix (Indy migration to
   TIdSSLIOHandlerSocketOpenSSL11, out of scope here).

Also folded into this commit because the operator asked the
literal question in the PR thread:

5. README: route table at the top
   Reorganises "What you get" into an explicit Path / What's there /
   Auth table so the answer to "do I hit /v1/chat/completions with
   the gateway_token, or is the web UI at 8088 separately?" is
   visible on the first scroll. Same hostname, same port -- both
   the web UI (at /) AND the OpenAI-compatible API (at /v1/*) are
   served from https://your-app.ondigitalocean.app/. DO App Platform
   terminates TLS in front of the container's port 8088; publicly
   it's the standard 443.
@FMXExpress
FMXExpress merged commit 0718bb4 into main Jun 13, 2026
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
DO App Platform build failed at the link step with:

  PasClaw.Logger.pas(54,3) Fatal: Can't find unit SyncObjs used by
  PasClaw.Logger

SyncObjs is the FPC TCriticalSection home -- used by PasClaw.Logger,
PasClaw.Otel, PasClaw.Tools.OutputCache, MCP, etc. It ships in
Debian's fp-units-fcl package, which fp-compiler does NOT pull as a
hard dependency on Bookworm. The PR FMXExpress#248 Dockerfile only requested
fp-compiler + fp-units-db + fp-units-misc, so SyncObjs (and several
other adjacent units) silently weren't present.

Fix: add fp-units-fcl, fp-units-base, fp-units-rtl to the apt
install. Comment block above the apt line maps each package to the
PasClaw unit / feature that needs it -- the next person hit by
"Can't find unit X" can grep that block and know exactly which
fp-units-* package to add (the FPC error itself doesn't give you
the package name; you have to reverse-map by trial-and-error
without this).

After-fix unit -> apt mapping:
  fp-units-base  -- Classes / SysUtils / StrUtils / DateUtils
  fp-units-fcl   -- SyncObjs (THE fix)
  fp-units-db    -- fcl-db / SQLite3Connection
  fp-units-misc  -- iconvenc (web_fetch)
  fp-units-rtl   -- belt-and-suspenders; usually pulled by fp-compiler
  lazarus-src    -- Masks (fs_grep's `include` glob filter)

No other PasClaw changes; `make smoke` green on the host system
which has all units installed (which is how this regression slipped
past -- the host runs apt install fpc which is the meta-package).
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
… wiring

The PR FMXExpress#250 root Dockerfile was written from scratch and missed
several units (`opensslsockets` in LocalVector.OrtProvision is the
latest casualty after `SyncObjs` from PR FMXExpress#251) AND didn't bring in
the libssl1.0 RPATH/multi-arch/buildx work from docker/Dockerfile
that was carefully sorted out in PR FMXExpress#121.

docker/Dockerfile has been the canonical "this builds and runs"
shape since PR FMXExpress#121 -- bookworm builder + `fpc` meta-package (pulls
every fp-units-*), multi-arch libssl1.0.2 fetched from
snapshot.debian.org's immutable archive, patched RPATH=$ORIGIN so
Indy's plain `dlopen("libssl.so")` resolves to the bundled
libraries. Container2wasm builds use the same Dockerfile via
`make C2W=1 browser` -> `--build-arg C2W=1`.

This PR:
  - Moves docker/Dockerfile to the repo root (overwrites the
    broken PR FMXExpress#250 root Dockerfile in place).
  - Adds the DigitalOcean App Platform first-boot wiring at the
    end of the runtime stage:
       COPY digitalocean/entrypoint.sh        /usr/local/bin/...
       COPY digitalocean/config.template.json /etc/pasclaw/...
       ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
       CMD ["gateway", "--addr", "0.0.0.0", "--port", "8088"]
  - Rewrites digitalocean/entrypoint.sh to handle BOTH the default
    case (no CMD args -> gateway) AND pass-through (`docker run
    pasclaw version` / `agent -m "..."` / etc. flow verbatim).
    The original PR FMXExpress#248 entrypoint always hardcoded `gateway`
    which would have broken the `docker run pasclaw version` use
    case that docker/README.md documents.
  - Updates docker/README.md: drops `-f docker/Dockerfile` from
    the build commands (no longer needed). The Quick start, multi-
    arch buildx, and Configuration sections all stay accurate.
  - Removes the now-unused docker/Dockerfile.

Net effect:
  - DigitalOcean App Platform now builds end-to-end (the
    `opensslsockets` Fatal goes away because fpc meta pulls
    fp-units-net implicitly).
  - Docker Hub / GHCR push paths from docker/README.md continue
    to work, just without the -f flag.
  - Container2wasm builds (`make C2W=1 browser`) continue to work
    -- the C2W=1 build-arg is preserved.
  - One Dockerfile, one canonical container shape, no more drift
    between the docker/ and root flavours.

PasClaw core untouched; `make smoke` green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants