Cloud

Deployment Generator

Production-grade Docker and Kubernetes manifest generation.

2 min readDocumentationEdit this page

Overview

The deployment generator creates production-ready Docker and Kubernetes artifacts from a single configuration object. All manifests follow security best practices including non-root containers, read-only filesystems, and resource limits.

Generate Manifests

typescript
import { generateDeployment } from '@axiljs/cloud'
 
generateDeployment({
  appName: 'payment-service',
  version: '1.4.2',
  port: 8080,
  replicas: 3,
  domain: 'payments.myapp.io',
  env: {
    DATABASE_URL: 'postgres://...',
    LOG_LEVEL: 'info',
  },
  resources: {
    cpuRequest: '100m',
    cpuLimit: '500m',
    memoryRequest: '128Mi',
    memoryLimit: '512Mi',
  },
})

This creates a deploy/ directory with three files.

Generated Files

Dockerfile

Multi-stage build with Node 22 Alpine, non-root user, and health check.

dockerfile
FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
 
FROM node:22-alpine AS runner
RUN addgroup -g 1001 -S appgroup && \
    adduser -S appuser -u 1001 -G appgroup
WORKDIR /app
COPY --from=builder /app/package*.json ./
RUN npm ci --omit=dev
COPY --from=builder /app/dist ./dist
USER appuser
EXPOSE 8080
CMD ["node", "dist/main.js"]

docker-compose.yml

For local development and testing.

kubernetes.yaml

Full production manifests including:

  • Deployment — rolling update strategy, security context, probes
  • Service — ClusterIP on port 80
  • HorizontalPodAutoscaler — CPU-based scaling
  • PodDisruptionBudget — minimum availability during updates
  • Ingress — (when domain is provided) TLS-ready routing

Dry Run Mode

Generate manifests as strings without writing to disk. Useful for CI/CD pipelines and API endpoints.

typescript
const manifests = generateDeployment({
  appName: 'my-service',
  version: '1.0.0',
  port: 3000,
}, true) // dryRun = true
 
manifests.forEach(m => console.log(m.filename, m.content))

Configuration Reference

OptionTypeDefaultDescription
appNamestring—Application name (RFC 1123)
versionstring—Image tag / version
portnumber—Container port
replicasnumber3Initial replica count
domainstring—Ingress hostname (optional)
registrystring—Container image registry
envobject—Environment variables
resourcesobjectSensible defaultsCPU/memory requests and limits
minReplicasnumber2HPA minimum
maxReplicasnumber10HPA maximum
targetCPUnumber70HPA target CPU utilization %
healthPathstring'/health'Probe path

Help improve the documentation

AxilJS is open source and documentation improvements are welcome.

AxilJS DocumentationMIT License · Built by SyntaxilitY