Skip to main content

generate-dockerignore-from-gitignore

As the name implies, this package generates a .dockerignore for you based on .gitignore rules found in your source tree.

Why generate this file, you ask? Because there are a number of differences between .dockerignore and .gitignore rule processing which can make it non-trivial to make your Docker file tree match your local git tree.

Generating your .dockerignore file based on your configured .gitignore rules means you only have to think about which files should not be distributed with your project only once. This also can promote reproducible builds by ensuring that the only files your Docker context has access to are those files that are tracked by your git repository.

The following differences between .dockerignore vs .gitignore processing are handled by this tool:

behavior .gitignore .dockerignore
plain patterns without slashes or wildcards ⏬️ match recursively ⬆️ match top-level only
separate per-directory ignore files ✅ allowed ❌ not allowed
local .git/info/exclude file ✅ included -
global core.excludesFile file ✅ included -

The code's handling of these behavioral differences is tested using actual git and Docker calls, followed by validation that the resultant git source trees are equal to the Docker build contexts.

References:

Installation

pip install generate-dockerignore-from-gitignore

Usage

usage: generate-dockerignore [-h] [-C DOCKER_ROOT] [-v] [-o OUTPUT] [PATH ...]

.dockerignore file generator based on .gitignore file(s)

positional arguments:
  PATH                  gitignore file(s), or directories under git source control (which will be
                        searched for **/.gitignore).

options:
  -h, --help            show this help message and exit
  -C DOCKER_ROOT, --docker-root DOCKER_ROOT
                        Docker context directory to chdir into before continuing
  -v, --verbose         Output per-file logging to stderr
  -o OUTPUT, --output OUTPUT
                        File path for generated .dockerignore rule output, or - for stdout
                        (default: .dockerignore)

Metadata

Release files for generate-dockerignore-from-gitignore 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for generate-dockerignore-from-gitignore 0.1.3
File Size Uploaded
generate_dockerignore_from_gitignore-0.1.3.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for generate-dockerignore-from-gitignore 0.1.3
File Interpreter ABI Platform
generate_dockerignore_from_gitignore-0.1.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 14.0 kB

Release files / generate_dockerignore_from_gitignore-0.1.3.tar.gz

Download URL generate_dockerignore_from_gitignore-0.1.3.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9be8a93883bae92352dd77643c553b1d6428283f41afed9a6e4623437d1cb4b6
BLAKE2b-256 checksum
How to use checksums
20a7fdccc4e085f3b5c8fa0f377c38010f1b917627b06ccafbb2a54c9a098645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release files / generate_dockerignore_from_gitignore-0.1.3-py2.py3-none-any.whl

Download URL generate_dockerignore_from_gitignore-0.1.3-py2.py3-none-any.whl
Size 4.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
887dca2b7ddfa5107c04d898647d780ce4bca49e7adac404e60c41881b25dd3a
BLAKE2b-256 checksum
How to use checksums
14681cb421410c723e881fefb895ddebe40e7cb0e40f8cf89eb687105d52d0ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page