Search code examples
djangodockergitignore

Docker files to be ignored on .gitignore


I'm new to docker. I've finalized dockerizing a Django projet of mine. What files and/or folders should I add to my .gitginore before pushing the changes to the project? Or no files should be added? I'm not talking about my .dockerignore file.


Solution

  • You should include any files that don't need to be in the final distribution or will be built when the container is built. Depending on your build process, this might include what is compiled for static assets (JS/CSS), Python packages downloaded by pip in venv as the build process might download again for each new build, any keys/secrets/passwords should not be committed to the .git repo as well, any caches or temporary files.

    With docker builds, I prefer to keep them isolated so that only code is copied and then the rest is built by the docker build process. So packages are installed by pip and the config/keys/passwords are passed into the docker container as environment variables. Also, I typically put .git into the .dockerignore so the entire git repository isn't copied into the docker image.

    You might find these two links helpful: