Skip to content

Using Flavors

Now that you understand flavors and JSON Patch, let’s see how to use them in practice.

Most EMB commands accept the --flavor flag:

Terminal window
emb <command> --flavor production

The flag comes after the command.

Build production images:

Terminal window
emb resources build --flavor production

This applies the production flavor, changing:

  • Docker target from development to production
  • Environment variables as configured

Compare base vs flavored configuration:

Terminal window
# Base configuration
emb config print
# With production flavor
emb config print --flavor production

Check specific values using the defaults section:

Terminal window
emb config print | grep -A 3 "^defaults:"
defaults:
docker:
tag: ${env:DOCKER_TAG}
target: development
Terminal window
emb config print --flavor production | grep -A 3 "^defaults:"
defaults:
docker:
tag: ${env:DOCKER_TAG}
target: production

Start services with production settings:

Terminal window
emb up --flavor production

This:

  1. Applies the flavor patches
  2. Builds images with the production target
  3. Starts services with production environment variables

Flavors are perfect for CI/CD pipelines:

Terminal window
# Development builds (default)
emb resources build
emb up -d
npm test
# Staging deployment
emb resources build --flavor staging
docker push myregistry/app:staging
# Production deployment
emb resources build --flavor production
docker push myregistry/app:latest

Components can add their own flavor patches:

Terminal window
cat api/Embfile.yml | grep -A 5 "^flavors:"
flavors:
production:
patches:
- op: replace
path: /resources/image/params/target
value: production

This ensures the API uses the production Docker target when building with --flavor production.

When both project and component define the same flavor:

  1. Project-level patches apply first
  2. Component-level patches apply second

This lets you:

  • Set global defaults at project level
  • Override specific components as needed

You’ve completed the EMB tutorials! You now know how to:

  • Hello World: Minimal configuration and auto-discovery
  • Fullstack App: Tasks, environment variables, Docker Compose
  • Microservices: Dependencies and build ordering
  • Production Ready: Multi-stage builds and flavors

Happy building!