Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊDevOps for Python servicesModule 1 Β· Docker & Containers Β· Recapβ€ΊπŸŽ― Review: DevOps module 1 recapscenario21 / 104
+80 XP
Task
Build `docker_image_tag(commit_sha, branch, env)` returning the deterministic image tag used in promotion pipelines: 1. Format: `image:<branch>-<short_sha>-<env>` 2. `short_sha` = first 7 chars of `commit_sha` (the git convention). 3. Branch slashes become dashes (`feature/foo` β†’ `feature-foo`) so the tag is registry-safe. 4. If `env == "prod"`, drop the branch segment entirely: `image:<short_sha>-prod` (prod tags are SHA-only β€” branch info is noise after merge). 5. Empty branch or empty sha β†’ `"image:invalid"` (defensive β€” never push a half-built tag).
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…