Skip to content

Deployment

Deploying a PAM application means answering three questions:

  1. How does the code reach the server? A container image, a release directory synced over SSH, or a bundle built with pam build.
  2. What keeps it running? pam start under a supervisor you already have (a container runtime, Kubernetes, systemd), or PAM’s own process manager (pam up, pamd).
  3. How do you roll out a new version? A reload with SIGHUP, a readiness-gated pam 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.

Whichever path you choose, check these first:

  • Production dependencies only: pam composer install --no-dev --optimize-autoloader.
  • Environment: set PAM_ENV=production and keep secrets in the environment or a 0600 env file, never in the repository.
  • Listen address: bind 0.0.0.0 (pass PAM_HOST to listen()) only when a proxy or container network sits in front; otherwise keep the default 127.0.0.1.
  • Proxies: list your load balancer in trustedProxies or PAM_TRUSTED_PROXIES so client addresses and rate limits are correct.
  • Errors: leave exposeErrors off (the default).
  • Health: give your orchestrator a liveness and a readiness URL. Nimbus HealthEndpoints answers /ready with 503 while a worker drains.
  • Migrations: run them once per release, before traffic moves (pam bin/migrate in the web template).
  • Extensions: consider an explicit extension profile for leaner workers.

Run pam doctor and pam test before every release.

In production you run a supervised cluster: one master that owns the listening sockets and N PHP workers.

Terminal window
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.

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:

Dockerfile (final stage)
FROM gcr.io/distroless/cc-debian12:nonroot
COPY --from=pam /opt/pam /opt/pam
COPY --from=vendor /app /app
COPY --from=vendor --chown=65532:65532 /app/storage /app/storage
ENV 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=3000
WORKDIR /app
USER 65532:65532
EXPOSE 3000
STOPSIGNAL SIGTERM
ENTRYPOINT ["/opt/pam/bin/pam"]
CMD ["start", "index.php", "--workers", "4", "--max-requests", "100000", "--graceful-timeout", "25000"]
Terminal window
docker build -t acme/orders-api .
docker run --rm -p 3000:3000 --read-only --tmpfs /tmp acme/orders-api

Start 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.

The PAM repository includes a Helm chart for Nimbus applications in deploy/helm/nimbus, built around that image:

Terminal window
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.

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:

Terminal window
pam deploy:remote [email protected] --init # first time: shared/.env and a systemd user service
pam deploy:remote [email protected] --workers 4 # every release
pam deploy:remote --dry-run # print the ssh and rsync commands only

The 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 release

The 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.

When one host runs several applications, describe them in pam.toml and let PAM converge the host to it:

pam.toml
schema_version = 1
[applications.api]
kind_code = 1
script = "index.php"
workers = 4
env_file = ".env.production"
health_check_url = "http://127.0.0.1:3000/api/ping"
Terminal window
pam config:check pam.toml # validate
pam plan # preview, changes nothing
pam apply # create, restart, scale or stop applications to match

pam plan never starts the daemon, writes state or sends signals, so it is safe in CI. See Declarative Deploys.

Without an orchestrator, PAM’s own process manager keeps applications running after your terminal closes and restarts them when they crash:

Terminal window
pam up index.php --name api --workers 8 --env-file .env.production \
--health-check-url http://127.0.0.1:3000/api/ping
pam ps
pam logs api --follow
pam reload api
pam save # remember the running list
pam startup --install # install a systemd user service that restores it at boot

Process Management covers health checks, restart policies, logs and pam monit.

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:

Terminal window
pam build --entry index.php --output release
release/
├── 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.json

The 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.

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.