Sikau

DevOps and deployment · Day 12 · about 30 min

Configuration per environment

One image everywhere; env_file and variable interpolation in Compose.

Build once, configure everywhere

The same image should run in development, staging and production — only the configuration changes. The twelve-factor app rule: keep config in the environment. Compose reads it from env_files and interpolates ${VARIABLES} from your shell.

env_file and ${VAR:-default}

services:
  api:
    build: .
    ports:
      - "3000:3000"
    env_file:
      - .env.production
    environment:
      APP_VERSION: ${APP_VERSION:-dev}

The rest of this lesson

  • Twelve-factor configexplain
  • Interpolation in Composeexplain
  • What runs?predict
  • Interpolation formsmatch
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 14 lessons of DevOps and deployment