Build Ordering
When you run emb resources build, EMB analyzes dependencies and determines the correct build order.
The Dependency Graph
Section titled “The Dependency Graph”Our microservices project has this dependency structure:
base ├── api (depends on base) └── worker (depends on base)
gateway (no dependencies)When you run emb resources build:
- base builds first (no dependencies)
- api and worker build after base completes
- gateway can build at any point (no dependencies)
EMB guarantees dependencies are built before their dependents. The order of independent components (like gateway) is not guaranteed.
Building All Resources
Section titled “Building All Resources”emb resources buildEMB will:
- Analyze the dependency graph
- Determine a valid build order
- Build each component one by one
- Ensure dependencies complete before dependents
Building a Single Component
Section titled “Building a Single Component”When you build a specific component:
emb resources build workerEMB automatically builds dependencies first:
- Checks if
base:imageexists and is up-to-date - Builds
base:imageif needed - Then builds
worker:image
Dry Run
Section titled “Dry Run”See what would be built without actually building:
emb resources build --dry-runThis shows the build order and what images would be created.
Circular Dependencies
Section titled “Circular Dependencies”EMB detects and reports circular dependencies. If you accidentally create:
resources: image: dependencies: - worker:image
# worker/Embfile.ymlresources: image: dependencies: - api:imageEMB will fail with a clear error message explaining the cycle.
Cache and Rebuilds
Section titled “Cache and Rebuilds”EMB tracks when images were last built. It rebuilds when:
- Source files have changed
- A dependency was rebuilt
- You use
--force
Summary
Section titled “Summary”You’ve learned about microservices patterns in EMB:
- Base images - Shared foundations for consistency
- Dependencies - Declaring build order requirements
- Build ordering - Automatic resolution of the dependency graph
Next Tutorial
Section titled “Next Tutorial”Ready to learn about environment-specific configurations? Continue to Production Ready to explore:
- Multi-stage Docker builds
- Flavors for different environments
- JSON Patch operations