Docker hub enforced rate limits starting with November 2020.
Github Docker Image as package
- Mount the directory containing your template(s) to the container's /templates directory
- Mount the directory containing your variables file(s) directory /variables
- Pass needed env vars (any number)
- In your jinja2 template get OS environment variables plus your inserted environment vars with
environ('your_env_var')
- YAML
- JSON
- XML
- TOML
- HJSON
- JSON5
Check jinja2-cli commands for all supported formats.
docker run --rm \
-v **TEMPLATE_FOLDER**:/templates \
-v **VARIABLES_FOLDER**:/variables \
-e CUSTOM_ENV_VAR=**VALUE** \
dinutac/jinja2docker:latest /templates/json.j2 /variables/json.json --format=json > **OUTPUT_FILE**
Example 1:
docker run --rm \
-v $PWD/inputs/templates:/templates \
-v $PWD/inputs/variables:/variables \
-e DATABASE=mysql56 -e IMAGE=latest \
dinutac/jinja2docker:latest /templates/standalone.j2 /variables/variables.yml --format=yaml > docker-compose.yml
Example 2:
docker run --rm \
-v $PWD/inputs/templates:/templates \
-v $PWD/inputs/variables:/variables \
dinutac/jinja2docker:latest /templates/json.j2 /variables/json.json --format=json
template.json
Os: {{os}}
Flavour: {{flavour}}
Path: {{environ('PATH')}}
variables.json
{
"os" : "Linux",
"flavour": "CentOS"
}
result.json
Os: Linux
Flavour: CentOS
Path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin