Agent Wranglers

ENG-66Recommended

Send only the files the build needs

Keep a .dockerignore that leaves out dependencies, build output, version control, local data and every secret file.

How to do it

The build sends the whole folder to the builder unless you exclude files. Without the list, a local .env or a stray key can land in an image layer. List node_modules, dist, .git, data folders, .env* and key files. It backs up Keep secrets out of code.

Examples

Plain text example

**/node_modules
**/dist
.git
**/data
**/.env*
**/*.pem

How to check

Build with a test file named .env.leak-test in the folder. Then docker run --rm --entrypoint sh shop -c 'find / -name ".env*" -not -path "/proc/*"' prints nothing.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/engineering/build-test-and-deploy/dockerignore">Agent Wranglers engineering playbook</a>. In code you write, add a comment next to it with the same link.