Skip to main content

Generate dockerfiles from pip requirements.txt

Project description


Render a dockerfile from a template and pip requirements.txt. Docker caches each dockerfile command in it’s own layer. By breaking out requirements.txt, each pip requirement goes into its own layer and build time improves.

Handles all the syntax allowed by pip in requirements.txt

Things like comments, whitespace, line continuations etc. that might choke a simpler solution. Uses the actual parser from pip so guaranteed* compatibility

* or your money back


Start with a copy your regular Dockerfile called Dockerfile.tmpl

Replace the pip install command that looks something like this:

RUN pip install -r requirements.txt

with some standard django template tags like this:

{% for req in pip_requirements %}
RUN pip install --upgrade {{ req }}{% endfor%}

djtempl will pass in a tuple called pip_requirements into the template context.

python -t ./Dockerfile.tmpl -p ./requirements.txt -d ./Dockerfile.out -q


pip install djtempl is pure python and only requires django>=1.8.0


Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djtempl-1.0.1.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

djtempl-1.0.1-py2-none-any.whl (5.8 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page