GitLab CI taking 25min to deploy a single Lambda, how do I speed this up?
Hey folks, I'm losing my mind here. We've got a fairly simple Node.js Lambda that gets packaged and deployed via GitLab CI, but the pipeline is taking 25 minutes end-to-end. Most of that time seems to be just... waiting.
Our setup:
- Docker executor on a Hetzner box (16 CPU, plenty of RAM)
- npm install, build, zip, then aws lambda update-function-code
- Nothing fancy, no tests taking forever
I've already:
- Switched to npm ci instead of install
- Enabled Docker layer caching
- Moved artifacts to fast storage
But it's STILL slow. Anyone else hitting this? Is it just the nature of Lambda deployments or am I missing something obvious? Would switching to GitHub Actions help or is it the same issue?
Edited at 26 Mar 2026, 11:47
Check if your Docker executor is pulling the image every run—that alone can eat 5-10min. Add pull_policy: if-not-present to your .gitlab-ci.yml. Also, what's your artifact transfer doing? If you're uploading the zip to S3 or similar before the Lambda update, that could be slow. Consider using IAM role auth directly and skip the intermediate storage. Last thing: enable BuildKit for faster builds—https://docs.docker.com/build/buildkit/
Ah good point! Yeah, I checked and we were pulling the image fresh every time. Added pull_policy: if-not-present and it shaved off like 6 minutes already. The artifact transfer was also slower than expected, but caching the Docker layers helped a lot there too. Thanks for the nudge in the right direction!
Glad you got some wins! One thing I'd check next—are you zipping the whole node_modules folder? For Lambda, you can often strip dev dependencies and non-essential files. I use npm ci --omit=dev + a simple script to remove heavy stuff (like @types/* if you're not bundling TypeScript). That alone saved us like 8min on a similar setup. Also, if your Lambda is under 50MB uncompressed, consider skipping the zip step entirely and using aws lambda update-function-code with a direct S3 upload—sometimes faster than local packaging.
also try switching to esbuild instead of webpack if you're using it, cuts our lambda builds in half
Pro tip: use Lambda layers for node_modules so you only zip/upload your actual code each deploy, cuts our times by like 70%.