When building container images, never copy the entire build context blindly. Add a .dockerignore (and/or use targeted COPY paths) to ensure sensitive files and local artifacts can’t be baked into the image—especially when using COPY . ..
Practical standard:
.env, .venv/, __pycache__/, *.pyc (and other environment/credential files).COPY requirements.txt ./ then install, and only copy the needed source directories.Example .dockerignore:
.env
.venv/
__pycache__/
*.pyc