Skip to content

Docker Builds

Guide to building and deploying Docker images from the monorepo.

Overview

The monorepo produces three main Docker images:

ImageSourcePurpose
emprops/apiapps/apiJob Queue API server
emprops/emprops-apiapps/emprops-apiEmProps REST API
emprops/utilsapps/utilsUtility services

Building Images

Build Individual Images

bash
# Build API image only
pnpm build:docker:api

# Build EmProps API image only
pnpm build:docker:emprops-api

# Build Utils image only
pnpm build:docker:utils

Build and Push

bash
# Build and push to registry
pnpm build:docker:api:push
pnpm build:docker:emprops-api:push
pnpm build:docker:utils:push

Build All Images

bash
# Build all images in parallel (faster)
pnpm build:docker:all

# Build and push all images
pnpm build:docker:all:push

Build Process

The scripts/docker-build-api.js script handles the build process:

  1. Production Build - Runs pnpm build:prod first (skipped for utils)
  2. Prepare Docker - Runs prepare-docker-build.js in the app directory
  3. Docker Build - Builds with --platform linux/amd64
  4. Push (optional) - Pushes to registry and triggers Railway redeploy

Custom Tags

bash
# Build with custom tag
node scripts/docker-build-api.js api --tag v1.2.3

# Build with tag and push
node scripts/docker-build-api.js emprops-api --tag staging --push

# Build without cache
node scripts/docker-build-api.js api --no-cache

Parallel Build Script

The build:docker:all command uses scripts/docker/build-all-parallel.sh which:

  • Builds all three images concurrently
  • Color-codes output per service (cyan/magenta/green)
  • Fails fast if any build fails
  • Reports final status

Machine Images

The GPU worker machine image has separate build commands:

bash
# Build machine image
pnpm machine:build

# Build and push machine image
pnpm machine:build:push

Local Testing

After building, test images locally:

bash
# Pull latest (if using registry)
pnpm docker:api:pull
pnpm docker:emprops-api:pull

# Run locally
pnpm docker:api:run
pnpm docker:emprops-api:run

# Check health
pnpm docker:api:status
pnpm docker:emprops-api:status

Best Practices

  1. Always test locally before pushing to registry
  2. Use semantic tags for releases (v1.2.3)
  3. Use latest only for development/staging
  4. Check health endpoints after deployment
  5. Monitor logs during initial rollout

Released under the MIT License.