Deployment
Deploying a PAM application means answering three questions:
- How does the code reach the server? A container image, a release directory synced over SSH, or a bundle built with
pam build. - What keeps it running?
pam startunder a supervisor you already have (a container runtime, Kubernetes, systemd), or PAM’s own process manager (pam up,pamd). - How do you roll out a new version? A reload with
SIGHUP, a readiness-gatedpam deploy, or your orchestrator’s rolling update.
This page gives you the map and a working starting point for each path. The Operations section goes into production tuning, clustering, process management and security.
Preparing the Application
Section titled “Preparing the Application”Whichever path you choose, check these first:
- Production dependencies only:
pam composer install --no-dev --optimize-autoloader. - Environment: set
PAM_ENV=productionand keep secrets in the environment or a0600env file, never in the repository. - Listen address: bind
0.0.0.0(passPAM_HOSTtolisten()) only when a proxy or container network sits in front; otherwise keep the default127.0.0.1. - Proxies: list your load balancer in
trustedProxiesorPAM_TRUSTED_PROXIESso client addresses and rate limits are correct. - Errors: leave
exposeErrorsoff (the default). - Health: give your orchestrator a liveness and a readiness URL. Nimbus
HealthEndpointsanswers/readywith503while a worker drains. - Migrations: run them once per release, before traffic moves (
pam bin/migratein thewebtemplate). - Extensions: consider an explicit extension profile for leaner workers.
Run pam doctor and pam test before every release.
Running the Server
Section titled “Running the Server”In production you run a supervised cluster: one master that owns the listening sockets and N PHP workers.
pam start index.php --workers 8 --max-requests 100000 \ --graceful-timeout 25000 --admin-address 127.0.0.1:3010| Signal | Effect |
|---|---|
SIGHUP |
Zero-downtime reload: start a complete new generation of workers, wait until it is ready, then drain the old one. A generation that fails to boot is discarded and the old one keeps serving. |
SIGTERM or SIGINT |
Stop accepting new work, finish in-flight requests for up to --graceful-timeout milliseconds (default 15000), then exit 0. |
--max-requests N recycles a worker after N requests the same way: the replacement starts first, and only then does the old worker drain. Inside PHP, pam_draining() returns true once the current worker starts draining, so readiness endpoints can answer 503 while in-flight requests finish. See Clustering for every option.
Containers
Section titled “Containers”The official Nimbus skeleton ships a production Dockerfile. It installs a pinned, checksum-verified PAM release, runs pam composer install --no-dev, warms the Arcano schema cache, and copies the result into a distroless image that runs as an unprivileged user with a read-only root filesystem:
FROM gcr.io/distroless/cc-debian12:nonrootCOPY --from=pam /opt/pam /opt/pamCOPY --from=vendor /app /appCOPY --from=vendor --chown=65532:65532 /app/storage /app/storageENV PAM_HOME=/opt/pam/share/pam \ PAM_EXTENSION_DIR=/opt/pam/lib/php/extensions \ PHPRC=/opt/pam/etc/php.ini \ PHP_INI_SCAN_DIR=/opt/pam/etc/conf.d \ PATH=/opt/pam/bin:/usr/local/bin:/usr/bin:/bin \ PAM_ENV=production \ PAM_HOST=0.0.0.0 \ PAM_PORT=3000WORKDIR /appUSER 65532:65532EXPOSE 3000STOPSIGNAL SIGTERMENTRYPOINT ["/opt/pam/bin/pam"]CMD ["start", "index.php", "--workers", "4", "--max-requests", "100000", "--graceful-timeout", "25000"]docker build -t acme/orders-api .docker run --rm -p 3000:3000 --read-only --tmpfs /tmp acme/orders-apiStart from the skeleton package or copy its Dockerfile into your project. A prebuilt image of the skeleton is published for amd64 and arm64 on every PAM release as ghcr.io/push-in/nimbus-skeleton.
Kubernetes With Helm
Section titled “Kubernetes With Helm”The PAM repository includes a Helm chart for Nimbus applications in deploy/helm/nimbus, built around that image:
helm install orders deploy/helm/nimbus \ --set image.repository=ghcr.io/acme/orders-api --set image.tag=1.4.2 \ --set existingSecret=orders-env| Value | Default | Purpose |
|---|---|---|
pam.workers |
4 |
PHP workers per pod. |
pam.maxRequests |
100000 |
Recycle a worker after N requests. |
pam.gracefulTimeoutMs |
25000 |
How long SIGTERM waits for in-flight requests. |
pam.taskWorkers |
0 |
Task workers for queues and the scheduler. |
preStop.sleepSeconds |
5 |
Lets endpoints update before draining starts. |
terminationGracePeriodSeconds |
40 |
Must exceed preStop.sleepSeconds plus the graceful timeout; rendering fails otherwise. |
probes.* |
/health, /ready |
Startup and liveness on /health, readiness on /ready. |
migrations.enabled |
false |
Run bin/migrate as a pre-install and pre-upgrade hook Job. |
autoscaling.enabled |
false |
Horizontal Pod Autoscaler on CPU. |
podDisruptionBudget.enabled |
true |
Keep at least one pod during voluntary disruptions. |
Pods run as UID 65532 with a read-only root filesystem, no capabilities and the RuntimeDefault seccomp profile; /tmp and /app/storage are writable volumes.
Servers Over SSH
Section titled “Servers Over SSH”pam deploy:remote ships the project to a Linux server with your system ssh and rsync, installs production dependencies there, runs bin/migrate when it exists and activates the release through PAM’s process manager:
pam deploy:remote --dry-run # print the ssh and rsync commands onlyThe server needs PAM installed for the deploy user. Releases live under pam-apps/<name> in that user’s home unless you pass --path:
pam-apps/my-app/├── releases/<UTC timestamp>/ one directory per release├── shared/.env linked into every release and passed as --env-file├── shared/storage/ linked as storage/├── state/ the application's own pamd state└── current -> releases/<id> the active releaseThe first release starts with pam up; later releases switch with the readiness-gated pam deploy, which only moves traffic once the new release answers. The five newest releases are kept (--keep N). Store defaults such as host, workers and healthCheckUrl in the deploy section of pam.json.
Declarative Hosts
Section titled “Declarative Hosts”When one host runs several applications, describe them in pam.toml and let PAM converge the host to it:
schema_version = 1
[applications.api]kind_code = 1script = "index.php"workers = 4env_file = ".env.production"health_check_url = "http://127.0.0.1:3000/api/ping"pam config:check pam.toml # validatepam plan # preview, changes nothingpam apply # create, restart, scale or stop applications to matchpam plan never starts the daemon, writes state or sends signals, so it is safe in CI. See Declarative Deploys.
The Process Manager
Section titled “The Process Manager”Without an orchestrator, PAM’s own process manager keeps applications running after your terminal closes and restarts them when they crash:
pam up index.php --name api --workers 8 --env-file .env.production \ --health-check-url http://127.0.0.1:3000/api/pingpam pspam logs api --followpam reload apipam save # remember the running listpam startup --install # install a systemd user service that restores it at bootProcess Management covers health checks, restart policies, logs and pam monit.
Bundles With pam build
Section titled “Bundles With pam build”pam build creates a new directory with a copy of your project, the pam binary, its PHP library and a manifest.json that records the size and SHA-256 of every file:
pam build --entry index.php --output releaserelease/├── app/ your project (without .git, .pam, .env, node_modules and target)├── bin/pam├── bin/pam-run launcher: runs bin/pam app/index.php with lib/ on the library path├── lib/libphp.so└── manifest.jsonThe output directory must not exist, and vendor/autoload.php must already be installed. The project is copied as it is, so run pam composer install --no-dev first if you do not want development dependencies in the bundle.
Rolling Out and Rolling Back
Section titled “Rolling Out and Rolling Back”| You run with | Roll out a new version | Roll back |
|---|---|---|
pam start in a container |
Your orchestrator’s rolling update; each pod drains on SIGTERM. |
Redeploy the previous image tag. |
pam start under systemd |
Replace the code, then systemctl reload (sends SIGHUP). |
Restore the previous release directory and reload. |
pam up / pam deploy:remote |
pam deploy NAME /path/to/release switches only after the new release is healthy. |
pam rollback NAME restores the previous healthy release. |
For gradual traffic shifting between two releases, the traffic:* commands run a weighted ingress with live error-rate gates. See Process Management.
Next Steps
Section titled “Next Steps”- Production: worker counts, memory, limits and proxies.
- Clustering: every
pam startoption and the admin control plane. - Security & Bundle Integrity: verifying what you ship.