Skip to content

Interview PrepDelivery · Core

Containers and Pipelines for a Node Service ​

These are the backend engineer's view of each topic. The DevOps module goes much deeper, and each answer links to it.

28. How do you package a Node.js application in Docker? ​

The short answer

Use a multi-stage Dockerfile. The build stage installs all dependencies with npm ci and compiles TypeScript. The final stage starts from a small Node base image, installs production dependencies only, copies the compiled output, runs as the non-root node user, and starts with node directly so signals reach your process. Copy package.json and the lockfile before the source, so dependency installation is cached between builds. Add a .dockerignore so node_modules, .env and .git never enter the image.

dockerfile
# syntax=docker/dockerfile:1
FROM node:24-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci                                         # (1)
COPY . .
RUN npm run build

FROM node:24-slim
ENV NODE_ENV=production
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev && npm cache clean --force   # (2)
COPY --from=build /app/dist ./dist                 # (3)
USER node                                          # (4)
EXPOSE 3000
CMD ["node", "dist/server.js"]                     # (5)
  1. All dependencies for building, cached as long as the lockfile does not change.
  2. Production dependencies only in the final image.
  3. Only the compiled output is copied, not the source or the build tools.
  4. Not root, so a compromised app cannot do as much damage.
  5. node directly, in exec form, so SIGTERM reaches Node and graceful shutdown works. npm start can swallow signals.
text
# .dockerignore
node_modules
dist
.env*
.git
coverage

Deeper: building Node images small and multi-stage builds.

29. What is Docker Compose, and when is it useful? ​

The short answer

Docker Compose describes a set of containers, their networks, volumes, environment and ports, in one compose.yaml file, and starts them all with docker compose up. It is ideal for local development, where a developer needs the API, PostgreSQL, Redis and a queue running together with one command, and for small single-host deployments. It is not a production orchestrator for many machines: it has no multi-host scheduling, limited self-healing and no rolling deploys across a cluster.

yaml
services:
  api:
    build: .
    ports: ["3000:3000"]
    environment:
      DATABASE_URL: postgres://app:app@db:5432/shop           # (1)
      REDIS_URL: redis://cache:6379
    depends_on:
      db: { condition: service_healthy }                      # (2)
  db:
    image: postgres:18
    environment: { POSTGRES_USER: app, POSTGRES_PASSWORD: app, POSTGRES_DB: shop }
    volumes: [pgdata:/var/lib/postgresql]
    healthcheck: { test: ["CMD", "pg_isready", "-U", "app"], interval: 5s }
  cache:
    image: redis:8
volumes:
  pgdata:
  1. Services reach each other by service name, db and cache, on Compose's private network.
  2. Wait until PostgreSQL is actually ready, not just started.

Deeper: Docker Compose and its limits in production.

30. What Kubernetes concepts should a backend engineer understand? ​

The short answer

Enough to ship and debug your own service. A Pod runs your container. A Deployment keeps a number of identical pods running and does rolling updates. A Service gives those pods one stable name and address. An Ingress or Gateway routes outside HTTP traffic in. ConfigMaps and Secrets inject configuration. Probes decide readiness and liveness. Requests and limits reserve and cap CPU and memory. A HorizontalPodAutoscaler adds pods under load. Namespaces separate teams or environments. And kubectl get, describe, logs and exec are how you find out what went wrong.

ConceptWhat it does for your service
PodRuns one instance of your container
DeploymentKeeps N pods running; rolling updates and rollback
ServiceStable DNS name, such as orders.default.svc, load-balanced across pods
Ingress or Gateway APIRoutes api.shop.example/orders to the Service
ConfigMap, SecretConfig and secrets as env vars or files
Readiness and liveness probesTraffic only to ready pods; restart stuck ones
Requests and limitsScheduling guarantees; CPU throttling and memory kills above limits
HorizontalPodAutoscalerMore pods when CPU or a metric rises
Job, CronJobOne-off and scheduled tasks, such as migrations or reports

Two things that surprise backend engineers:

  1. A memory limit is a hard wall. Exceed it and the container is killed with OOMKilled. Set Node's heap below it, for example --max-old-space-size at about 75% of the limit.
  2. CPU limits throttle, they do not kill. A CPU-throttled Node process shows high latency with no errors.

Deeper: what Kubernetes is and Deployments.

31. What is Helm, and how does it help deploy Kubernetes applications? ​

The short answer

Helm is a package manager for Kubernetes. A chart is a set of templated Kubernetes manifests plus a values.yaml of defaults. You install it as a release with environment-specific values, such as more replicas and a different hostname in production, and Helm renders the templates, applies them, and records each version so you can upgrade and roll back with one command. It removes copy-paste between environments and lets teams share standard charts for databases, ingress controllers and their own services.

bash
helm upgrade --install orders ./charts/orders-api \
  --namespace shop --values values-production.yaml \
  --set image.tag=3f9a1c2 --wait --atomic           # --atomic rolls back automatically if the upgrade fails
helm rollback orders 41

Deeper: Helm and upgrades and rollbacks.

32. What is CI/CD, and what stages would you include for a Node.js service? ​

The short answer

Continuous integration means every change is merged often and automatically built and checked, so problems appear within minutes. Continuous delivery means every change that passes is packaged and ready to deploy at the push of a button; continuous deployment goes further and deploys it automatically. For a Node service, the stages are: install with npm ci and a cache; lint and type-check; run the automated checks; scan dependencies and code for vulnerabilities and secrets; build the Docker image; scan the image; push it with an immutable tag; deploy to staging with migrations and smoke checks; then promote the same image to production with a safe rollout.

① npm cicached② linttsc③ checksautomated④ scandeps, secrets⑤ buildimage⑥ pushSHA tag⑦ stagingsmoke⑧ prodcanaryfast, cheap stages first; the same image moves from ⑥ to ⑧
Fail fast, build once, promote. Cheap checks run first, so most problems are caught in a minute. The image built at ⑤ is the one that reaches production, so what ran in staging is exactly what runs in production.

Deeper: CI and CD, continuous delivery versus deployment and fast checks first.

33. How would you build a CI/CD pipeline using GitHub Actions? ​

The short answer

A workflow is a YAML file in .github/workflows/, triggered by events such as pull requests and pushes to main. Jobs run on runners and contain steps, which run commands or reusable actions. A typical Node pipeline has a check job on every pull request, with checkout, setup-node with npm cache, npm ci, lint, type-check and the automated checks; then on main, a build job that builds and pushes the image, and deploy jobs for staging and production, protected by environments with required reviewers. Use OIDC to get short-lived cloud credentials instead of storing keys.

yaml
name: ci
on:
  pull_request:
  push: { branches: [main] }

permissions: { contents: read, id-token: write, packages: write }    # (1)

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v5
        with: { node-version: 24, cache: npm }                       # (2)
      - run: npm ci
      - run: npm run lint && npm run typecheck && npm run check

  image:
    if: github.ref == 'refs/heads/main'
    needs: check                                                    # (3)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: docker/login-action@v3
        with: { registry: ghcr.io, username: "${{ github.actor }}", password: "${{ secrets.GITHUB_TOKEN }}" }
      - uses: docker/build-push-action@v6
        with: { push: true, tags: "ghcr.io/shop/orders-api:${{ github.sha }}" }   # (4)

  deploy-production:
    needs: image
    runs-on: ubuntu-latest
    environment: production                                         # (5)
    steps:
      - run: ./scripts/deploy.sh "${{ github.sha }}"
  1. Least privilege for the workflow token; id-token: write allows OIDC login to a cloud.
  2. Cache npm downloads between runs.
  3. Only build if checks passed.
  4. Tag the image with the commit SHA.
  5. The production environment can require approval and hold production-only secrets.

Deeper: GitHub Actions concepts, secrets and environments and protecting secrets from pull requests.

34. How does Jenkins support continuous integration and delivery? ​

The short answer

Jenkins is a self-hosted automation server. Pipelines are defined as code in a Jenkinsfile in the repository, usually in the declarative syntax of stages and steps, and run on agents, machines or containers that a controller schedules work onto. Plugins connect it to source control, credentials, Docker, Kubernetes and clouds. It is very flexible and common in large companies with existing infrastructure, at the cost of running, securing and upgrading Jenkins and its plugins yourself.

groovy
pipeline {
  agent { docker { image 'node:24-slim' } }
  stages {
    stage('Install') { steps { sh 'npm ci' } }
    stage('Check')   { steps { sh 'npm run lint && npm run typecheck && npm run check' } }
    stage('Image') {
      when { branch 'main' }
      steps { sh 'docker build -t registry.example/orders-api:$GIT_COMMIT .' }
    }
  }
  post { failure { echo 'Build failed' } }
}

Deeper: Jenkinsfile and controllers and agents.

35. What is Azure DevOps, and how can it be used in a deployment pipeline? ​

The short answer

Azure DevOps is Microsoft's suite for the software lifecycle: Repos for git, Boards for work items, Artifacts for package feeds, Test Plans, and Pipelines for CI/CD. Azure Pipelines are defined in azure-pipelines.yml as stages, jobs and steps or tasks, running on Microsoft-hosted or self-hosted agents. Deployments target environments with approvals and checks, and service connections hold the credentials to reach Azure, Kubernetes or other clouds, ideally with workload identity federation instead of stored secrets.

yaml
trigger: [main]
stages:
  - stage: Build
    jobs:
      - job: build
        pool: { vmImage: ubuntu-latest }
        steps:
          - task: NodeTool@0
            inputs: { versionSpec: '24.x' }
          - script: npm ci && npm run lint && npm run check && npm run build
          - task: Docker@2
            inputs: { command: buildAndPush, repository: orders-api, containerRegistry: acr-connection, tags: $(Build.SourceVersion) }
  - stage: Production
    dependsOn: Build
    jobs:
      - deployment: deploy
        environment: production          # approvals and checks are configured on the environment
        strategy:
          runOnce:
            deploy:
              steps:
                - script: ./scripts/deploy.sh $(Build.SourceVersion)

Deeper: Azure Pipelines and approvals.

36. What is object storage, and how is it used for file uploads? ​

The short answer

Object storage, such as Amazon S3, Azure Blob Storage, Google Cloud Storage or Cloudflare R2, stores files as objects in buckets, each with a key, the data and metadata, accessed over HTTP. It is cheap, practically unlimited, very durable, and shared by every app instance, so it is where uploads belong instead of local disk. The best pattern is the presigned URL: your API checks the user and the file, then returns a short-lived URL that lets the browser upload straight to the bucket, so large files never pass through your Node servers.

browseryour APIobject storage① name, type, size② presigned URL, 5 min③ PUT the file directly④ done⑤ verify object
Your API grants permission; storage carries the bytes. The large upload in ③ goes straight to object storage. Your servers only sign a short-lived permission and verify the result.
ts
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'

const s3 = new S3Client({})                                                     // (1)

app.post('/api/uploads', requireUser, async (req, res) => {
  const { contentType, size } = UploadRequest.parse(req.body)                   // (2)
  const key = `uploads/${req.user!.id}/${randomUUID()}`                         // (3)
  const url = await getSignedUrl(s3, new PutObjectCommand({
    Bucket: config.UPLOADS_BUCKET, Key: key, ContentType: contentType, ContentLength: size,
  }), { expiresIn: 300 })                                                       // (4)
  res.json({ url, key })
})
  1. Credentials come from the workload's cloud role, not from config.
  2. Validate type and size first, for example images up to 10 MB only.
  3. The server picks the key, never the client's file name.
  4. The URL works for 5 minutes and only for this key, type and size.

After the upload, check the object's real type, scan it, and only then make it visible (secure uploads).

Combine chapters into one PDF

Pick the chapters you want. They print in the order you pick them.

Interview Prep
Production & Operations
Performance
Scaling
Edge
Deploying
Delivery
Observability
Other topics
Nothing picked yet