DevOps
Back to journalDevOps

Docker + Azure DevOps: a CI/CD recipe that halves release time

May 12, 202511 min readHSHarshal Singh

The exact pipeline structure, caching tricks and image layering rules that took our deploys from 18 minutes to under 9.

Slow pipelines kill momentum. Every minute a deploy takes is a minute someone is context-switching out of focus. Here's the pipeline shape I now use as a template.

Multi-stage Dockerfiles

A two-stage Dockerfile with a slim runtime base is non-negotiable. Build dependencies should never ship to production.

FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:20-alpine
WORKDIR /app
COPY --from=build /app/.next ./.next
CMD ["npm", "start"]

Cache like you mean it

Azure DevOps cache tasks on node_modules and the .next/cache directory shaved nearly 7 minutes off cold builds in our case.

Tagged

#Docker#CI/CD#Azure
HS

Harshal Singh

Software Engineer · Mumbai, India

Get in touch

Keep reading

All posts →