Skip to content

Microservices

This tutorial explores how EMB handles complex projects with multiple interdependent components.

  • Four components - API, worker, gateway, and a shared base image
  • Component dependencies - Building images in the right order
  • Shared base images - DRY principle for Docker builds

We’ll use examples/microservices:

microservices/
├── .emb.yml # Project configuration
├── .env # Environment variables
├── docker-compose.yml # Service definitions
├── base/ # Shared base image
│ ├── Dockerfile
│ ├── Embfile.yml
│ └── utils.js
├── api/ # REST API
│ ├── Dockerfile
│ ├── Embfile.yml
│ ├── package.json
│ └── server.js
├── worker/ # Background worker
│ ├── Dockerfile
│ ├── Embfile.yml
│ ├── package.json
│ └── worker.js
└── gateway/ # API Gateway
├── Dockerfile
├── Embfile.yml
└── nginx.conf
Terminal window
emb components
COMPONENT NAME ID CREATED STATUS
--------------------------------------
worker
gateway
base
api

Four components, each with a specific role:

  • base - Shared Node.js base image with common utilities
  • api - REST API service
  • worker - Background job processor
  • gateway - Nginx reverse proxy
  1. Base Images - Creating shared base images
  2. Dependencies - Declaring component dependencies
  3. Build Ordering - How EMB resolves build order

You should have completed the Fullstack App tutorial first.