You push to main, the PaaS pipeline starts, the “Build” step prints the first few lines of output, and then nothing. Ten minutes later the deploy times out. The same build runs in 90 seconds on your laptop. The platform isn’t broken; the build is doing work it shouldn’t be doing.
What’s happening
A PaaS build runs in a sandboxed environment with constrained CPU and memory and a smaller filesystem cache than your laptop. Three classes of work that look fast locally turn pathological:
- Dependency resolution against a slow or rate-limited registry. npm with no lockfile, Composer with
--no-cache, pip pulling wheels over constrained egress. - Native compilation of dependencies you didn’t pull as prebuilt wheels.
node-gypbuilding from source;sharprebuilding libvips;cryptographycompiling OpenSSL bindings. - A
RUNstep that copies the source tree before installing dependencies, busting the layer cache on every commit.
The hang isn’t a hang. It is honest work in the wrong layer, with no progress output because the tool buffered stdout.
How to verify
Pull the raw build logs (most PaaS panels expose a “raw log” toggle) and find the last line before the gap. Common signatures:
node-gyp configureorgyp info spawn— native module compilation.Resolving dependenciesfor Composer with no further output — registry timeout.Building wheel for cryptography— OpenSSL compile.- A long silence right after
COPY . .— the next layer is downloading everything fresh because the cache key changed.
Reproduce locally against a clean cache (docker buildx build --platform linux/amd64). If the clean-cache build takes 12 minutes locally, the PaaS isn’t slow — your build is.
The fix
- Commit your lockfile.
package-lock.json,composer.lock,pipfile.lock,cargo.lock. Every build starts from the same dependency graph. - Restructure the Dockerfile to copy lockfile + manifest first, install dependencies, then copy source. The dependency-install layer caches on lockfile content, not source content.
- Pin to platforms with prebuilt binaries available.
node:20-slimonlinux/amd64instead ofnode:20-alpineif alpine forces source compilation of native modules. - Use the platform’s build cache where available — most managed PaaS expose a persistent cache mount for
~/.npm,~/.cache/composer,~/.cache/pip. - If the registry is the bottleneck, mirror it. A private package proxy (Verdaccio, Sonatype Nexus, GitHub Packages) inside the same network turns 30-second downloads into 1-second downloads.
A healthy PaaS build for a typical web application is two to four minutes. If yours is longer, the layer hierarchy is wrong before the registry is slow.
Stack Harbor’s Cloud PaaS practice templates the build pipeline as part of platform onboarding — we can audit yours.