Skip to content

dol/bash-envtpl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

bash-envtpl

Simple envtpl implementation in Bash

Details

Inspired by envtpl written in python this repo is basic equivalent in Bash. The main goal is to avoid the dependency of Python and pip within a Docker container. This saves about 50MB container size.

Most of the time a envtpl template file looks like this:

{% for key, value in environment('VAR_PREFIX_') %}{{ key|lower|replace('_','-') }}={{ value }}
{% endfor %}

The rendered template is stored to a file.

The bash function envtpl performs this work.

envtpl ENV_PREFIX TARGET_FILE [KEY_DELIMITER='_'] [KEY_DELIMITER_REPLACEMENT='-'] [VALUE_DELIMITER='=']

Usage

  1. Copy/paste file envtpl.sh or bash function envtpl into your entrypoint script
  2. Call envtpl function
#!/usr/bin/env bash
# Source envtpl.sh if file was copied
. envtpl.sh
# E.g APP_API_KEY=mykey stores api.key:mykey into /etc/app/production.conf
envtpl APP_ /etc/app/production.conf '_' '.' ':'

Requirements

  • Bash 4.0 (Released 2009)

About

Simple envtpl implementation in bash

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages