Package: docker-jinja3
docker-jinja - djForked fromhttps://github.com/Grokzen/docker-jinjaExtend your dockerfiles with Jinja2 syntax and logic.Create new filter and functions for Jinja with simple datasource files.InstallationInstall from pypi withpip install docker-jinjaTo install in development mode, first navigate to root of project and then runpip install -r dev-requirements.txt; pip install -e .. It is recommended to install inside a virtualenv to avoid conflicts with dependencies.Quickstart guideCreate a Dockerfile.jinja that contains all regular Dockerfile build steps and the jinja syntax. For exapmle:$ cat Dockerfile.jinja 
FROM {{ OS }}
MAINTAINER {{ MAINTAINER }} 

ARG {{ ARG1 }}Rundjcommand. For example:dj --dockerfile Dockerfile.jinja --outfile Dockerfile --env OS=ubuntu:12.04 --env MAINTAINER=Grokzen --env ARG1=foobar --config test-config.jsonAnd you will get the output:FROM ubuntu:12.04
MAINTAINER Grokzen

ARG foobarConfiguration filesIt is possible to create predefined configuration files with settings, enviroment variables and datasources.djtries to load the following configuration files in the following order:/etc/dj.yaml/etc/dj.json~/.dj.yaml~/.dj.json$CWD + '.dj.yaml'$CWD + '.dj.json'YAML is the file format to prefer but json is also supported.Currently it is not possible to automatically load a config file next to the source Dockerfile.DatasourcesIf you want to extend the Jinja syntax with additional filters and global functions you have the datasource pattern to help you.A datasource file is a python script that can contain any code you want so you can extenddjto be capable to perform any task you want.You can telldjto load a datasource file in multiple ways.In any config file create a keydatasourceswith a list of strings paths pointing to all files thatdjshould import. (Must be absolute path)Point to a file with cli key -s/--datasource anddjwill load that file. (Relative paths is supported)Add a python file to contrib folder and it will auto load during execution.Global functions
################A global function is a regular python function that you can call from jinja. These functions can be used to perform any usefull task you require.To create a global function you define a method within a datasource and its name should starts with_global_and then follow by the name you want to use in your Dockerfile.For example if you have the following code:def_global_foo():return"bar"You can call it from jinja with:RUNecho'{{ foo() }}'and it will render intoRUNecho'bar'Filter functions
################To create a new filter function you define a method within a datasource and its name should starts with_filter_and then follow by the name you want to use in your Dockerfile.For example if you have the following codedef_filter_bar(arg):returnarg.upper()You can call it from jinja with:RUNecho'{{ "opa"|bar }}'and it will render intoRUNecho'OPA'Other rendering enginesCurrently only Jinja2 is supported as rendering engineSupported python version3.10ContributeOpen an Issue on github describing the problem you have.If you have a fix for the problem or want to add something to contrib library, open a PR with your fix. The PR must contain some test to verify that it work if it is a bugfix or new feature.  All tests in all supported python environments must pass on TravisCI before a PR will be accepted.All PR:s should have their commits squashed to a single commit.LicenseSee LICENSE file. (MIT)