Docker
This repository includes a ready-to-use Dockerfile and docker-compose.yml for containerized development and production builds.
Quick start (recommended)
Use the provided npm scripts:
npm run docker:build
npm run docker:upUseful helpers:
npm run docker:logs— tail app logsnpm run docker:shell— open a shell in the app containernpm run docker:test— run tests inside the containernpm run docker:down/npm run docker:stop
What the Dockerfile does
The root Dockerfile is multi-stage:
- builder (
node:20-alpine)
- installs build tooling (
python3,make,g++) for native modules likebcrypt - runs
npm ci - runs
npm run build:cito producedist/
- runtime (
node:20-alpine)
- installs only production dependencies (
npm ci --omit=dev) - copies
dist/from the builder stage - runs as a non-root user
- starts the compiled server via
node dist/src/boot/bootstrap.js
Production build target
To build the runtime stage explicitly:
npm run docker:build:prodThis corresponds to docker build --target runtime ....
Docker Compose (local dev)
The included docker-compose.yml is optimized for local development:
- mounts the repo into the container (
.:/app) for live iteration - runs
npm run devin the app container - starts PostgreSQL by default
- includes Redis under the
optionalprofile
Start dev services:
docker-compose up -dStart dev services including Redis:
docker-compose --profile optional up -dEnvironment variables
Compose passes common settings (examples):
NODE_ENV,HOST,PORTDB_CONNECTION,DB_HOST,DB_PORT,DB_DATABASE,DB_USERNAME,DB_PASSWORD
You can override these via your shell environment or a .env file that Docker Compose reads.
Ports and health checks
The Docker setup uses two different conventions:
- Compose maps
3000:3000by default and setsPORT=3000. - Health checks in both
Dockerfileanddocker-compose.ymlcallhttp://localhost:7777/health.
ZinTrust projects default to port 7777 unless configured otherwise. If your container is configured to listen on 3000, update the health check URL accordingly (or set your server port to 7777 and map ports as you prefer).
Persistent data
Compose uses named volumes for infrastructure:
postgres_datafor Postgresredis_datafor Redis
Application storage/logs are repo-mounted in dev mode; for production you typically mount only what you need (logs, uploads, backups) and keep your container filesystem immutable.