Skip to content

Docker deployment v1 — multi-stage Dockerfile with bundled OpenSSL 1.0 - #121

Merged
FMXExpress merged 2 commits into
mainfrom
claude/docker
Jun 1, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/docker

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

Self-contained Docker deployment as a new docker/ directory plus a root .dockerignore. No host source changes — all Pascal, Makefile, configs untouched.

docker build -f docker/Dockerfile -t pasclaw:dev . produces a ~110 MB image that runs pasclaw gateway out of the box. Multi-arch ready (linux/amd64 + linux/arm64 via buildx).

Pipeline

  1. debian:bookworm builder — apt install fpc fp-units-db fp-units-misc lazarus-src libsqlite3-dev, then make get-indy && make. Uses Debian-packaged FPC 3.2.2 (which is what bookworm ships) rather than upstream freepascal/fpc:* because our Makefile is written against /usr/lib/x86_64-linux-gnu/fpc/3.2.2/units/x86_64-linux/ — the upstream image puts units under /usr/local/lib/fpc/ and would need a Makefile fork.
  2. openssl-1.0 stage — fetches libssl1.0.2_1.0.2u-1~deb9u7_${arch}.deb from snapshot.debian.org's immutable debian-archive (20240331T102506Z, a frozen URL that won't rot). Picks the right arch via $TARGETARCH for buildx; verified URLs return 200 for both amd64 and arm64. Extracts libssl.so.1.0.2 + libcrypto.so.1.0.2.
  3. debian:bookworm-slim runtime — pasclaw binary + bundled OpenSSL 1.0 .so files at /opt/pasclaw/, symlinks for Indy's dlopen('libssl.so') pattern, RPATH=$ORIGIN via patchelf so the bundled libs resolve before /usr/lib/x86_64-linux-gnu/. Non-root user (uid 1000), PASCLAW_HOME=/home/pasclaw/.pasclaw, healthcheck probes /v1/models. ENTRYPOINT pasclaw, CMD gateway.

Why bundled OpenSSL 1.0

IndySockets/Indy master targets OpenSSL 0.9.8–1.0.x and explicitly refuses to operate against 1.1+ (IdSSLOpenSSLHeaders.pas:23114 — "OpenSSL 1.1.0 made MAJOR changes that we do not support yet"). Modern distros ship OpenSSL 3.x as libssl.so.3 only, so without bundled 1.0 the binary would have no working TLS. ~5 MB extra; deletes whenever Indy lands 1.1/3 upstream.

Out of scope (sketched in docker/README.md)

  • docker-compose.yml with profiles for gateway / agent / serve / channels
  • .github/workflows/docker.yml for multi-arch ghcr publish
  • Image smoke tests in CI (requires Docker daemon access)
  • Distroless / chainguard slimmer runtime
  • Dockerfile.dev with FPC + source bind-mount for inner-loop work
  • The Indy OpenSSL 3 upgrade itself

Test plan

  • .dockerignore excludes build/, .git/, vendor/Indy/, samples, IDE state
  • All apt packages confirmed present on bookworm (fpc, fp-units-db, fp-units-misc, lazarus-src, libsqlite3-dev)
  • Snapshot URLs return 200 for both amd64 and arm64; .deb contents verified to contain libssl.so.1.0.2 + libcrypto.so.1.0.2
  • Debian-packaged FPC 3.2.2 unit layout matches Makefile assumptions (/usr/lib/x86_64-linux-gnu/fpc/3.2.2/units/x86_64-linux/)
  • fpcres is in fp-compiler-3.2.2 (a fpc dep) — alternatives set up the unprefixed /usr/bin/fpcres symlink automatically
  • Manual: docker build -f docker/Dockerfile -t pasclaw:dev . — no daemon available in dev env, needs human verification
  • Manual: docker run --rm pasclaw:dev version — confirm bundled OpenSSL loads cleanly
  • Manual: docker run --rm -p 8088:8088 pasclaw:dev + curl localhost:8088/v1/models — confirm gateway boots, healthcheck passes
  • Manual: docker buildx build --platform linux/amd64,linux/arm64 -f docker/Dockerfile . — confirm multi-arch works

Generated by Claude Code

Adds a self-contained Docker build: `docker build -f docker/Dockerfile
-t pasclaw:dev .` produces a ~110 MB image that runs `pasclaw gateway`
out of the box. Multi-arch ready (amd64 + arm64 via buildx). No CI
wiring, no compose, no host-side changes — purely additive.

Pipeline:
  1. debian:bookworm builder — `apt install fpc fp-units-db
     fp-units-misc lazarus-src libsqlite3-dev`, then `make get-indy &&
     make`. Uses Debian-packaged FPC rather than freepascal/fpc:* upstream
     because our Makefile is written against the
     `/usr/lib/x86_64-linux-gnu/fpc/3.2.2/units/x86_64-linux/` layout
     apt produces; the upstream image puts units under
     `/usr/local/lib/fpc/` and would need a Makefile fork.
  2. openssl-1.0 stage — fetches `libssl1.0.2_1.0.2u-1~deb9u7_${arch}.deb`
     from snapshot.debian.org's immutable debian-archive
     (20240331T102506Z, a frozen URL that won't rot). Picks the right
     arch via $TARGETARCH for buildx; verified URLs return 200 for
     both amd64 and arm64. Extracts libssl.so.1.0.2 + libcrypto.so.1.0.2.
  3. debian:bookworm-slim runtime — pasclaw binary + bundled OpenSSL 1.0
     .so files at /opt/pasclaw/, symlinks for Indy's dlopen('libssl.so')
     pattern, RPATH=$ORIGIN via patchelf so the bundled libs resolve
     before /usr/lib/x86_64-linux-gnu/. Non-root user (uid 1000),
     PASCLAW_HOME=/home/pasclaw/.pasclaw, healthcheck probes
     /v1/models, ENTRYPOINT pasclaw, CMD gateway.

Why bundled OpenSSL 1.0: IndySockets/Indy master targets OpenSSL
0.9.8-1.0.x — its TLS path bails on 1.1+ (see
IdSSLOpenSSLHeaders.pas line 23114: "OpenSSL 1.1.0 made MAJOR changes
that we do not support yet"). Modern distros ship OpenSSL 3.x as
libssl.so.3 only, so without bundled 1.0 the binary would have no
working TLS. ~5 MB extra; deletes whenever Indy lands 1.1/3 upstream.

`.dockerignore` keeps the build context lean (~50 MB) — excludes
build/, .git/, vendor/Indy/ (fetched fresh in builder), samples,
IDE state, docker/vendor/ (reserved for future).

README in docker/ covers quick-start, multi-arch buildx, config
bind-mount patterns, the OpenSSL 1.0 rationale, image layout, and
explicit out-of-scope items (compose with profiles, CI multi-arch
publish, distroless runtime, dev Dockerfile, Indy upgrade).

Not in this v1 (deliberate scope cut, all sketched in docker/README.md):
  - docker-compose.yml with profiles for gateway/agent/serve/channels
  - .github/workflows/docker.yml for multi-arch ghcr publish
  - Image smoke tests in CI (requires Docker daemon access)
  - Distroless / chainguard slimmer runtime
  - Dockerfile.dev with FPC + source bind-mount for inner-loop work

No host code changes. All Pascal sources, Makefile, configs untouched
— this PR is `docker/` + `.dockerignore` only.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon

@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: 1ab994b497

ℹ️ 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 docker/Dockerfile
RUN apt-get update && apt-get install -y --no-install-recommends \
fpc \
fp-units-db fp-units-misc \
lazarus-src \

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 Use Bookworm's LazUtils path in the builder

With the default debian:bookworm builder, this installs Bookworm's lazarus-src 2.2.6 package (Debian package metadata), whose LazUtils sources include components/lazutils/masks.pas (Debian source tree). However, Makefile:68 passes -Fu/usr/lib/lazarus/3.0/components/lazutils, while src/pkg/tools/PasClaw.Tools.FS.pas:36 imports Masks. As a result, the subsequent RUN make cannot resolve that unit on the advertised default base image. Override LAZUTILS_DIR to Bookworm's 2.2.6 directory or use a compatible Lazarus package.

Useful? React with 👍 / 👎.

Comment thread docker/Dockerfile Outdated
# HTTP gateway; override with `docker run pasclaw <cmd>` to get agent /
# serve / status / etc.
ENTRYPOINT ["pasclaw"]
CMD ["gateway"]

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 Bind the container gateway to all interfaces by default

When the documented default docker run -p 8088:8088 pasclaw:dev invocation is used without a custom config, this starts gateway without --addr. ParseGw inherits Cfg.Gateway.BindAddr (src/cmd/PasClaw.Cmd.Gateway.pas:77), and the default is 127.0.0.1 (src/pkg/config/PasClaw.Config.pas:274). The process therefore listens only on the container loopback interface, so Docker's published host port cannot reach it even though the in-container health check passes. Include --addr 0.0.0.0 in the image's default command or otherwise provide a container-specific default.

Useful? React with 👍 / 👎.

Comment thread docker/Dockerfile
# Probe the gateway's model-listing endpoint — always returns 200 when
# the gateway is up, even with no providers configured.
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -fsS http://localhost:8088/v1/models > /dev/null || exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make the health check follow the configured port

When a mounted config.json changes gateway.port, or a user runs gateway --port <port>, the server listens on that selected port because ParseGw reads the config and CLI override (src/cmd/PasClaw.Cmd.Gateway.pas:78,106). This probe remains fixed on 8088, causing a healthy gateway to be reported as unhealthy. Either probe the configured port through an environment variable or document and enforce that containerized gateways must use port 8088.

Useful? React with 👍 / 👎.

…althcheck port

Three legit Codex findings on the Docker v1 PR — all fixed in place
on PR #121. No source changes; docker/ only.

  P1 — LAZUTILS_DIR pointed at the wrong directory for bookworm.
  The Makefile defaults to `/usr/lib/lazarus/3.0/components/lazutils`
  (Ubuntu noble layout), but Debian bookworm's lazarus-src package
  is 2.2.6+dfsg2-2 and installs to `/usr/lib/lazarus/2.2.6/`. The
  subsequent `make` step couldn't resolve the `Masks` unit imported
  by PasClaw.Tools.FS.pas, so the build would fail before producing
  build/pasclaw. Verified via Debian's package filelist API —
  bookworm path is /usr/lib/lazarus/2.2.6/components/lazutils/.
  Override LAZUTILS_DIR via `make LAZUTILS_DIR=…` arg; exposed as
  a build ARG so a future bookworm-→-trixie bump only needs one
  line in lockstep with the lazarus version.

  P1 — Gateway bound to 127.0.0.1 inside the container. PasClaw's
  default bind is 127.0.0.1 (sane for desktop CLI). Inside a
  container that means "container loopback only" — Docker's
  `-p 8088:8088` host port mapping can't reach it even though the
  in-container HEALTHCHECK still passes. The container would
  silently fail to serve any external traffic. Fix: CMD now
  explicitly passes `--addr 0.0.0.0`. Users who want a different
  bind override CMD.

  P2 — HEALTHCHECK port could drift from gateway port. If a
  mounted config.json set gateway.port to something other than
  8088, the gateway would listen there but the probe would still
  hit 8088. Fix: CMD now also passes `--port 8088` explicitly so
  the CLI flag wins over config and EXPOSE/HEALTHCHECK/CMD stay
  pinned to the same port. README documents the override pattern
  (rebuild or override both CMD and HEALTHCHECK at run time).

Verified that bookworm's lazarus-src ships `/usr/lib/lazarus/2.2.6/
components/lazutils/masks.pas` via Debian's package filelist API.
Local `make` still works on the dev host (lazarus 3.0) since the
ARG default doesn't affect the host build path.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
@FMXExpress
FMXExpress merged commit 08243a5 into main Jun 1, 2026
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
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 FMXExpress#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 FMXExpress#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 FMXExpress#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.
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