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.
More on Architecture & Design Decisions
How would you design a container build-and-deploy pipeline from commit to production?AdvancedWhen should you use Docker Compose, Swarm, ECS, or Kubernetes?IntermediateHow do you decide how many processes belong in one container?BeginnerHow do you design the config strategy for containerized apps (12-factor)?IntermediateHow would you containerize a legacy app that writes to local disk and holds sessions in memory?AdvancedAlpine or Debian-slim for a Python service?Intermediate