Skip to main content
Version: 4.0.0-preview

Containerize & Profile

Two related commands that produce and audit your container artifacts.

CommandAliasPurpose
containerizecGenerate Dockerfile + compose + Kubernetes from a template library.
profileprof, analyzeLint and optimize an existing Dockerfile or built image.

containerize

expressots containerize <target> [environment] [options]

Targets

TargetWhat it generates
docker(default) Dockerfile, optionally Dockerfile.development, plus .dockerignore.
composedocker-compose.yml (and .development.yml when applicable).
kubernetesDeployment / Service / ConfigMap / Ingress manifests.
k8sAlias for kubernetes.

Environments

EnvironmentPurpose
developmentDev image with hot-reload-friendly mounts.
stagingProduction-shaped image with looser security headers and verbose logging.
production(default) Hardened production image.
allGenerate every environment in one pass.

Presets

PresetWhat it dials in
standard(default) Multi-stage build, non-root user, healthcheck.
minimalSlim base image, single-stage, no extras.
secureDistroless or scratch final stage, hardened defaults.
fast-startupTrims warm-up; useful for serverless / Lambda.
devOptimized for local dev (volume mounts, watch).
multi-archBuildx-friendly Dockerfile for amd64 + arm64.

Options

OptionDefaultDescription
--presetstandardSee the preset table above.
--analyzetrueRun the project analyzer to discover ports, secrets, env files.
--skip-composefalseDon't emit compose files even for environments that normally include them.
--include-cifalseAlso emit a CI/CD pipeline (see cicd).
--ci-platformgithubgithub / gitlab / circleci / jenkins / bitbucket / azure / all.
--ci-strategycomprehensivebasic / comprehensive / security-focused.
--include-security-scanstrueAdd Trivy / npm audit jobs to the generated CI pipeline.
--include-e2efalseAdd an E2E test stage to the generated CI pipeline.
--deployment-strategyrollingrolling / blue-green / canary / recreate.

Examples

# Minimal production Dockerfile
expressots containerize docker production --preset minimal

# Secure production image + compose
expressots containerize docker production --preset secure

# Full Kubernetes set with blue-green deploy strategy
expressots containerize kubernetes production --deployment-strategy blue-green

# Dev compose with development overrides
expressots containerize compose development --preset dev

# Everything at once, including CI
expressots containerize docker all --include-ci --ci-platform github

Project analyzer

By default containerize runs an analyzer that scans expressots.config.ts, package.json, and your src/ tree to detect:

  • The app's listen port (falls back to 3000 today; an upcoming patch will honour the resolved port from bootstrap()).
  • The entry point file.
  • Required env vars and .env template generation.
  • Optional sidecar services (Postgres, Redis, RabbitMQ) when their providers are detected in package.json.

Pass --analyze=false to skip the scan and use generic defaults.


profile

Audit a Dockerfile or built image and report optimization recommendations.

expressots profile <action> [target] [options]
ActionPurpose
containerLint a Dockerfile (default: ./Dockerfile).
imageInspect a built image (profile image my-app:latest).
optimizeSuggest concrete edits (multi-stage split, base image swap, etc.).
reportProduce a full report combining the above.

Options

OptionDefaultDescription
--dockerfile -fDockerfilePath to the Dockerfile to analyze.
--formattexttext / json / html.
--severitylowlow / medium / high / critical. Filters the output.
--auto-fixfalseApply safe fixes in-place (multi-stage split, ENV ordering).
--output -ostdoutWrite the report to a file instead.
--include-securitytrueRun security checks (non-root user, healthcheck, etc.).
--include-sizetrueCompare layer sizes and report bloat hot-spots.

What profile checks

  • Base image freshness (LTS Node, distroless, slim variants).
  • Multi-stage build separation.
  • Layer ordering and cache effectiveness.
  • Non-root user.
  • Healthcheck presence.
  • .dockerignore coverage.
  • npm ci vs npm install (CI vs ad-hoc).
  • Known CVEs in the base image via Trivy (when installed).

Examples

# Quick lint of the default Dockerfile
expressots profile container

# Audit a built image with HTML report output
expressots profile report --format html --output reports/docker-audit.html

# Apply safe fixes in place
expressots profile optimize --auto-fix

See also

  • cicd: generate the CI pipeline that builds and publishes these images.
  • migrate: move from Heroku / Docker Compose to Kubernetes / Railway / Render / Fly.
  • templates: manage the cached Dockerfile / compose / K8s templates.