Deploying Pipal

From pnpm dev on a laptop to systemd and Caddy on a server.

intermediate10 min read

You can open Pipal on the computer where you started it. To open the same workspace from your phone, give the browser an HTTPS address and give the server a way to start at boot. The Linux files shipped with Pipal do those two jobs with Caddy and systemd.

In this chapter

  • Choose between the local watch loop and a one-off build.
  • Connect Caddy, systemd, and the browser at the same public URL.
  • Check an installation, add project tools, and update the checkout without moving the store.

Hono serves the local build

From the Pipal checkout, use Node.js 26.13.1 and pnpm 12.23.0. Install with pnpm install --frozen-lockfile, then run pnpm dev. It builds the web client first. After that, Vite watches and rebuilds the client files while Node watches the backend modules. Reload the browser after a client rebuild. Hono serves the files at the same Pipal URL as with a one-off build. The listener closes and reopens when Node restarts the backend. package.json package.json

For a one-off build, run pnpm build and then pnpm start. The latter runs start.mjs, which checks whether to set up a Node compile cache and then imports the server. Open http://127.0.0.1:8080 with the defaults. The token is in data/access-token. You can send a message with Local echo before connecting a remote model. Configuration, annotated explains how to change those defaults. start.mjs README.md

systemd owns the process and its directories

The shipped pipal.service
[Unit]
Description=Pipal AI workspace
Wants=network-online.target
After=network-online.target

[Service]
Type=exec
User=pipal
Group=pipal
WorkingDirectory=/opt/pipal
Environment=NODE_ENV=production
Environment=NODE_COMPILE_CACHE=/var/cache/pipal
Environment=PIPAL_CONFIG=/etc/pipal/config.toml
EnvironmentFile=-/etc/pipal/environment
ExecStart=/usr/local/bin/node packages/server/src/main.ts
Restart=on-failure
RestartSec=5s
TimeoutStopSec=30s
StateDirectory=pipal
StateDirectoryMode=0700
CacheDirectory=pipal
CacheDirectoryMode=0700
UMask=0077
NoNewPrivileges=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=strict
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
RestrictSUIDSGID=true
LockPersonality=true

[Install]
WantedBy=multi-user.target
deploy/linux/pipal.service
  1. Order at boot

    Request the network-online target and order Pipal after it. Reaching this target does not establish that a provider or project backend is reachable.

  2. Service account

    Run under the dedicated pipal account, with the checkout as the working directory.

  3. Startup settings

    The unit invokes Node at this absolute path and bypasses the local startup wrapper. The dash makes the environment file optional. Put API keys in that root-owned file, mode 0600.

  4. Failure and shutdown

    systemd waits five seconds to restart after failure and allows 30 seconds for a stop.

  5. State and cache

    systemd provisions private state and cache directories. The service writes chats under /var/lib/pipal. Node can rebuild the compile cache under /var/cache/pipal.

  6. Service restrictions

    The service gets private temporary directories and a mostly read-only filesystem. Home paths are hidden. The remaining directives restrict gaining privileges through exec, setting set-ID bits, access to kernel and control-group facilities, and changes to the process execution personality.

  7. Enable at boot

    Enabling the unit attaches it to the normal multi-user boot target.






[Service]






























deploy/linux/pipal.service

1 Order at boot

Request the network-online target and order Pipal after it. Reaching this target does not establish that a provider or project backend is reachable.

Select a block to see what systemd supplies before Node starts and which restrictions apply while it runs.

On the Linux server in Pipal’s deployment guide, the checkout lives at /opt/pipal. For a new installation, install and build it from an administrator’s account and create the dedicated pipal service user. Install deploy/linux/pipal.toml as /etc/pipal/config.toml with owner root:pipal and mode 0640, and the unit as /etc/systemd/system/pipal.service. For an existing installation, preserve the configured data directory, sign-in mode, and other local settings. Set ExecStart to the absolute path to the installed Node binary if it differs from /usr/local/bin/node. Run sudo systemctl daemon-reload so systemd sees the unit. deployment.md

Those locations keep the application, configuration, and data directoryThe private folder on the host where Pipal keeps conversations, uploads, sign-in records, and other state. apart. The installed TOML points to the profiles inside the checkout and stores private state under /var/lib/pipal. Put API keys in the root-owned, mode 0600 environment file if you use API-key models. The supplied unit starts with main.ts and gives Node the managed cache path in its environment. pipal.toml deployment.md

Deep diveWhat the packaged unit protects and what it leaves writable

ProtectSystem=strict makes the filesystem mostly read-only to the service. StateDirectory and CacheDirectory give it writable private locations for state and compile cache. PrivateTmp separates its temporary paths and ProtectHome=true hides home directories and /run/user. That last setting matters if you later give the service access to a rootless Docker socket. pipal.service deployment.md

NoNewPrivileges prevents gaining privileges through exec, and RestrictSUIDSGID restricts setting the set-user-ID and set-group-ID bits on files. The other directives restrict access to kernel settings, modules, logs and control groups, and lock the process execution personality. The service still has the privileges of its account and any engine or remote development account you connect. Node handles SIGTERM by stopping HTTP and closing its runtime. The unit sets an outer stop timeout of 30 seconds. pipal.service main.ts deployment.md

One public origin and one path prefix

Point DNS for your hostname at the server. Allow inbound TCP 80 and 443 for Caddy. Keep Pipal’s port 8080 and the ChatGPT sign-in port 1455 private, and keep SSH available from your administration network. Allow outbound DNS and HTTPS for certificate issuance and provider requests. Caddy is the reverse proxyA server that receives browser requests and forwards them to an application listening behind it., the process that takes the browser’s HTTPS request and sends it onward. It obtains the certificate and sends plain HTTP to Pipal’s loopback listener. deployment.md

From HTTPS to the loopback listener
  • Browser
  • Caddy Caddyfile
  • Pipal app.ts
  1. Browser → Caddy · HTTPS

    The browser sends a message

    In an existing chat, a signed-in browser sends POST /ai/api/v1/conversations/:id/messages with its session cookie and Origin: https://home.example.com.

  2. Caddy → Caddy · Match prefix

    Caddy selects the Pipal route

    The matcher covers /ai itself and its descendants. The fallback in the supplied Caddyfile returns 404.

  3. Caddy → Pipal · Loopback HTTP

    Caddy forwards the same path

    The proxy ends the HTTPS connection and forwards ordinary HTTP to 127.0.0.1:8080. It keeps the public Host and the /ai prefix.

  4. Pipal → Pipal · Host and Origin

    Pipal checks the request addresses

    The public Host must be allowed, and the write’s Origin must match the configured server.origin. The path reaches the API mounted under /ai.

  5. Pipal → Pipal · Session

    Pipal checks who sent the request

    The request needs a live session. Hono bounds the body and validates the JSON before submitting the message.

  6. Pipal → Caddy · 202 Accepted

    Pipal acknowledges the message

    A successful submission returns 202. The reply itself follows through the separate chat watch.

  7. Caddy → Browser · HTTPS reply

    Caddy returns the acknowledgement

    The browser keeps using its original HTTPS address for the conversation.

Browser
Caddy Caddyfile
Pipal app.ts

Browser → Caddy

The browser sends a message

In an existing chat, a signed-in browser sends POST /ai/api/v1/conversations/:id/messages with its session cookie and Origin: https://home.example.com.

The public request arrives over HTTPS. Watch what changes at Caddy and what must arrive intact at Pipal.

Build the client with pnpm build --base=/ai/. This makes /ai/ its base pathThe URL path prefix under which Pipal serves its web client and API., the URL prefix for the UI, assets, and API. Set server.origin to https://home.example.com for the example hostname. This is the browser’s scheme and host, with a port only if the public address uses a nondefault one. The Caddy matcher forwards both /ai and /ai/* with the prefix intact. deployment.md Caddyfile

If you have already enrolled a passkey, keep its hostname when updating the installation. Changing that hostname in server.origin makes startup refuse the existing passkey store. passkey-store.ts

Deep diveThe file that keeps the client and server on the same path

Vite’s build plugin checks the base and writes it into the web output.

packages/web/vite.config.ts
generateBundle() {
this.emitFile({ type: 'asset', fileName: 'pipal-base-path.txt', source: base + '\n' });
}

The file sits at packages/web/build/pipal-base-path.txt. Startup refuses a missing marker or an invalid base. Both sides accept a leading and trailing slash and path segments containing letters, digits, underscores, or hyphens. main.ts removes the final slash for Hono’s mount point, and app.ts strips the mount point when serving a file from the build directory. A request to bare /ai redirects to /ai/. The client uses Vite’s BASE_URL when constructing API calls. vite.config.ts main.ts app.ts api.ts

Check both sides before enrolling a passkey

Use the supplied Caddyfile with your hostname for a fresh Caddy installation. On a server with an existing Caddyfile, merge the site or add both the @pipal matcher and its handle block to the existing site. Preserve the other sites and the existing fallback. Validate the Caddy config, reload Caddy, then run sudo systemctl enable --now pipal. Put only mutually trusted apps on that origin. The security model explains why a second path on the hostname shares the browser boundary. deployment.md

The supplied config uses passkeys. On a fresh setup, open the public URL and enroll with the code from /var/lib/pipal/passkeys/setup-code on the host. The code expires after ten minutes. If it expires before enrollment, restart Pipal for a fresh one. Add a backup in Settings → Account → Passkeys. The Hono server explains enrollment and recovery. passkey-store.ts Settings.svelte

Give project work its own place

The signed-in owner enables each project locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project. in Settings → Workspace. Fresh installations start with all locations off. An upgrade can import a configured destination as described in Configuration. The SSH and Docker tables are mutually exclusive. Either location can be enabled alongside the local one. config.ts workspace-locations.ts

This machine. Enable it and choose Save changes. In the packaged deployment, Pipal creates projects under /var/lib/pipal/projects/, inside the unit’s writable state directory. Approved Bash commands run as pipal under the same unit restrictions and can access the chat database and saved model login. deployment.md development-workspace.ts

If you maintain an explicit extension list, include pipal.coding and pipal.bash for Developer. In a new Developer chat, use This machine and select or name a project in Runtime. Ask Developer to run pwd. The first send opens the folder, creating it if needed, and pins the chat to that location and project. deployment.md index.ts

SSH machine. Prepare a separate unprivileged Linux account with Bash, Node.js 18 or newer, and a writable projects directory. Keep that account away from Pipal’s credentials and the host’s rootful socket. For Docker workloads, give the account its own rootless engine and enable linger for its systemd user manager. deployment.md

Install the OpenSSH client on the Pipal host and give the service account a dedicated client key. Add its public key to the development account’s authorized_keys and record the verified server key in a known-hosts file. In /etc/pipal/development.ssh, define Host development with the remote HostName, and point IdentityFile and UserKnownHostsFile to files the unit can read, such as files under /var/lib/pipal/ssh/. deployment.md

For a project that uses Docker Compose, check the noninteractive login from the Pipal host. The command checks the directory is writable and should print pipal-dev, Node and Compose versions, and engine security options including name=rootless. deployment.md

Terminal window
sudo -u pipal -H ssh -T -F /etc/pipal/development.ssh \
-o BatchMode=yes -o StrictHostKeyChecking=yes -o ClearAllForwardings=yes \
-l pipal-dev development 'set -e
id -un
cd /home/pipal-dev/projects
test -w .
node --version
docker info --format "{{json .SecurityOptions}}"
docker compose version'

Set [extensions.development_workspace] as shown in Configuration, annotated, restart, and enable SSH machine in Settings → Workspace. With an explicit extension list, include pipal.coding and pipal.bash for the project tools and pipal.delegate for workers. In a new Developer chat, use SSH machine and select or name its project in Runtime. Ask for pwd to check the path. The development workspace covers project selection and persistent services. deployment.md

Docker. Use rootless Docker as pipal or a dedicated engine in a separate VM. Set DOCKER_HOST in the environment file. The packaged account’s default rootless storage is under /var/lib/pipal, alongside the database. Put the engine’s storage on a separate filesystem or set a quota to leave room for the database. Prepare a trusted Linux image with Bash, Node.js and GNU /usr/bin/timeout, and a plain local volume writable by container user 1000:1000. deployment.md project-shell.ts

Configure [extensions.project_shell] with an explicit extensions.enabled list that includes pipal.coding and pipal.bash, then restart. Enable Docker in Settings → Workspace and save to check the engine, image, and volume. Open a new Developer chat and use Docker, selecting it in Runtime if there is a choice. Ask Developer to run pwd and approve the call when prompted. Expect /workspace. Settings and Runtime both explain that shell commands run without network access. The Docker project follows what the engine starts for each call. deployment.md workspace-choice.ts

Deep diveHow the local rootless Docker socket reaches the service

On the local rootless setup, the engine runs under the same Linux account as Pipal. The deployment guide starts that account’s systemd user manager with linger, so it can run without an interactive login. Check the engine reports rootless mode, its intended storage directory, and the controllers needed for the container limits. The user manager and engine live outside the Pipal unit. deployment.md

The unit’s default home protection hides the socket under /run/user. The guide’s drop-in switches to ProtectHome=tmpfs and binds in the socket alone with BindReadOnlyPaths. The leading dash lets Pipal start if the socket is absent. Reload systemd after adding the drop-in, and restart Pipal after Docker recreates its socket so the unit binds the current one. This applies to the Docker location and to Docker commands issued from This machine on the packaged service. deployment.md

A successful health check can coexist with an unavailable workspace. If a configured location fails its startup connection check, it stays selected and Settings → Workspace shows Unavailable with the reason. Fix the cause and use Retry connection. If the first enable attempt fails, fix the cause, select the location again and save. Restart to apply TOML edits or refresh an obsolete socket bind mount. workspace-locations.ts DeveloperWorkspace.svelte

Deep diveHow to verify optional public web access

Add pipal.public-web to the service’s extension list and restart Pipal. The service account needs outbound HTTPS access to mcp.exa.ai for search and r.jina.ai for page reading. Both work without API keys, including when the chat’s project shell runs offline in Docker. config.example.toml public-web.ts

The signed-in /ai/api/v1/extensions endpoint shows which web extensions are enabled on the host. To verify extraction from a chat, choose Developer and a tool-capable model, ask it to use read_url on https://nodejs.org/api/fs.html, and check that the tool returns page content. Hosted search has its own model compatibility check. app.ts isolated-project.test.ts hosted-search-capabilities.ts

If a lookup fails, the tool result names the service that could not be reached or that reported a rate limit. A request has a 30-second deadline and a 1 MiB response limit. On a successful page read, truncated: true means the host shortened the content to fit the tool result. public-web.ts

Update the build alongside the server

Choose the release tag or revision you intend to run. Stop Pipal before backing up its data directory or replacing the checkout. Back up /etc/pipal/ separately with the same private access as the store. When things go wrong covers which files to copy. Update the checkout, run pnpm install --frozen-lockfile and rebuild with the deployed base path. If the unit changed, install it again and reload systemd. Start Pipal against the same data directory, repeat both health checks, and read the version in the journal’s ready event. deployment.md main.ts

Once the service is live, where does your browser’s trust end and a model’s or tool’s authority begin? The security model follows that boundary through the installation.

Recap

  • Both local modes serve the built client through Hono. Development mode rebuilds the web files and watches backend modules.
  • Caddy owns the public HTTPS connection. Pipal checks the public origin and mounts the routes at the path recorded by the build.
  • systemd runs Pipal under its own account and manages state and cache directories. Enable and verify project locations in Settings → Workspace.
Check yourself
  1. The local health check works, but sign-in from the local HTTP page gets 403 after you configure HTTPS. What should you open?
    • The public HTTPS URL
    • The same loopback URL in a private tab
    • The cache directory
    Answer and explanation

    The public HTTPS URL

    The health route accepts the listener host. The API checks that the browser’s Origin on a write matches the public origin.

  2. You change the public path from /ai/ to /tools/ai/ on the same origin. What needs to change?
    • The passkey hostname
    • The build base and Caddy matcher
    • The storage directory
    Answer and explanation

    The build base and Caddy matcher

    The base sets the UI and API paths. The proxy must forward that path intact, and the origin stays the same.

  3. The service is healthy after startup, but an enabled Developer location failed its probe. Where can you see why and retry?
    • The phone’s install menu
    • The certificate expiration date
    • Settings → Workspace
    Answer and explanation

    Settings → Workspace

    The health route can respond even when a project location fails its probe. Settings shows the reason and lets you retry after fixing it.

  1. The local health check works, but sign-in from the local HTTP page gets 403 after you configure HTTPS. What should you open?

  2. You change the public path from /ai/ to /tools/ai/ on the same origin. What needs to change?

  3. The service is healthy after startup, but an enabled Developer location failed its probe. Where can you see why and retry?

In the source

Book contents

Search the book