Good Code
The good version excludes dependency folders, local build output, secrets, logs, and repository metadata from the build context.
Lesson 01
Keep the Docker build context small and intentional so builds are faster, safer, and easier to reproduce.
node_modules
.git
.env
.next
coverage
dist
*.log
Dockerfile*
compose*.yaml# Everything in the repository is sent to the builder.The good version excludes dependency folders, local build output, secrets, logs, and repository metadata from the build context.
The bad version sends the whole repository to the builder. That makes cache invalidation noisy and increases the chance of copying sensitive or irrelevant files.