Skip to content
Daniel J. Saldaña edited this page Oct 29, 2026 · 1 revision

Docker

🇪🇸 Español

The Dockerfile has three targets. Images use Next.js standalone output, Node.js 24 and an unprivileged user. They build without credentials or database access.

Target Purpose
runner Default target: the web application on port 4000.
collector Imports the inventory from Blob Storage into PostgreSQL.
migrator Pre-deployment job that applies database migrations.
docker build -t cloud-inventory-web .
docker build --target collector -t cloud-inventory-collector .
docker build --target migrator  -t cloud-inventory-migrator .

docker run --rm --env-file .env -v "$PWD/certs:/app/certs:ro" cloud-inventory-migrator
docker run --rm --env-file .env -v "$PWD/certs:/app/certs:ro" cloud-inventory-collector azure
docker run -d --name cloud-inventory -p 4000:4000 --env-file .env \
  -v "$PWD/certs:/app/certs:ro" cloud-inventory-web
  • .env is passed at runtime and never copied into images.
  • Mount a private CA in /app/certs and set DB_SSL_CA_PATH when PostgreSQL uses one.
  • Use host.docker.internal as DB_HOST to reach a PostgreSQL running on the host.
  • Docker uses its own node_modules, independent from your local install.

Health checks

Endpoint Checks
/api/health/ Liveness of the process.
/api/ready/ Database and schema.

Compose

compose.example.yaml shows the expected order: the migrator must complete successfully before the web and the collector start.

Migrations in production

Run migrations as a separate job against the writer endpoint, with a DDL user (DB_MIGRATION_*), before sending traffic to the new version. The web process never executes DDL, and migrations never run automatically on every replica start. Then run db:check, start the new replicas and wait for /api/ready/ to return 200.

See the migration procedure in docs/backend.md.

Clone this wiki locally