Dependencies
When one component’s image depends on another, you need to tell EMB so it builds them in the right order.
Declaring Dependencies
Section titled “Declaring Dependencies”In a component’s Embfile, use the dependencies array:
cat worker/Embfile.ymldescription: Background job worker
resources: image: type: docker/image publish: true dependencies: - base:image
tasks: test: description: Run worker tests script: npm test
scale: description: Show scaling info script: echo "Worker concurrency is controlled by WORKER_CONCURRENCY env var" executors: - localThe key part is:
resources: image: type: docker/image dependencies: - base:image # Build base:image firstThis tells EMB: “Before building worker:image, make sure base:image is built.”
Dependency Format
Section titled “Dependency Format”Dependencies use the format component:resource:
base:image- Theimageresource of thebasecomponentapi:image- Theimageresource of theapicomponent
Viewing Dependencies
Section titled “Viewing Dependencies”See all resources and their dependencies:
emb resources ID NAME TYPE PUBLISHABLE REFERENCE------------------------------------------------------------------------------- api:image image docker/image ✓ microservices/api:latest base:image image docker/image microservices/base:latest gateway:image image docker/image ✓ microservices/gateway:latest worker:image image docker/image ✓ microservices/worker:latestThe API Component
Section titled “The API Component”The API also depends on base:
cat api/Embfile.ymldescription: REST API service
resources: image: type: docker/image publish: true dependencies: - base:image
tasks: test: description: Run API tests pre: - lint script: npm test
lint: description: Run linter script: npm run lintBoth api and worker depend on base, meaning base must be built first.
Why Declare Dependencies?
Section titled “Why Declare Dependencies?”Without explicit dependencies, EMB might try to build worker before base exists, causing the build to fail. Dependencies ensure:
- Correct build order - Parents built before children
- Parallel optimization - Independent components can build simultaneously
- Rebuild detection - If
basechanges, dependents are rebuilt
Next Step
Section titled “Next Step”Continue to Build Ordering to see how EMB resolves the complete build graph.