Interview Prep/Docker/Architecture & Design Decisions

How do you structure Dockerfiles in a monorepo with shared libraries?

AdvancedProductionArchitecture & Design Decisions
Answer

Use the repo root as context with per-service Dockerfiles (docker build -f services/api/Dockerfile .), a Dockerfile.dockerignore per service that whitelists needed paths, a common base stage, and buildx bake to orchestrate. With BuildKit named contexts (--build-context shared=../libs) you can pull shared directories without making the context huge.

All Docker questions Roadmap: Docker & containers

More on Architecture & Design Decisions