Skip to content

Flavors Introduction

Flavors let you define environment-specific configuration variants without duplicating your entire configuration.

Different environments need different settings:

SettingDevelopmentStagingProduction
NODE_ENVdevelopmentstagingproduction
LOG_LEVELdebuginfowarn
Docker targetdevelopmentdevelopmentproduction

Without flavors, you’d need separate config files for each environment.

Flavors define patches that modify your base configuration:

flavors:
production:
patches:
- op: replace
path: /env/NODE_ENV
value: production

When you use --flavor production, EMB:

  1. Loads your base configuration
  2. Applies the flavor’s patches
  3. Uses the modified configuration

List defined flavors:

Terminal window
emb config print | grep -A 22 "^flavors:"
flavors:
staging:
patches:
- op: replace
path: /env/NODE_ENV
value: staging
- op: replace
path: /env/LOG_LEVEL
value: info
production:
patches:
- op: replace
path: /env/NODE_ENV
value: production
- op: replace
path: /env/LOG_LEVEL
value: warn
- op: replace
path: /defaults/docker/target
value: production
- op: add
path: /defaults/docker/platform
value: ${env:DOCKER_PLATFORM:-linux/amd64}
Terminal window
emb config print | grep -A 3 "^env:"
env:
DOCKER_TAG: ${env:DOCKER_TAG:-latest}
NODE_ENV: ${env:NODE_ENV:-development}
LOG_LEVEL: ${env:LOG_LEVEL:-debug}
Terminal window
emb config print --flavor production | grep -A 3 "^env:"
env:
DOCKER_TAG: ${env:DOCKER_TAG:-latest}
NODE_ENV: production
LOG_LEVEL: warn

Notice how NODE_ENV and LOG_LEVEL changed from templates to fixed production values!

Flavors are ideal for:

  • Environment differences - dev/staging/production settings
  • Feature flags - enabling/disabling features per environment
  • Resource sizing - different memory limits, replicas
  • Docker targets - development vs production builds

Components can also define flavors in their Embfiles:

Terminal window
cat api/Embfile.yml | head -15
description: Production-ready API with multi-stage builds
resources:
image:
type: docker/image
publish: true
params:
target: development
tasks:
test:
description: Run tests
pre:
- lint
script: npm test

When both project and component define the same flavor, both sets of patches are applied (component first, then project). If they touch the same key, the project-level patch wins.

Continue to JSON Patch to learn about the patch operations in detail.