A simple shellscript to easily substitue config files based on env variables
This little project should make the configuration part of small docker projects easier.
NOTE:
- For now you must have the bash shell installed. Especially alpine is using
sh
by default (apk add --no-update --no-cache bash
). key=value
pairs without spaces are not supported at the moment (key = value
is supported)
Just define an env prefix, the key and the value of a config file:
cat /etc/kopano/ical.cfg
:
[...]
# File with RSA key for SSL
ssl_private_key_file = /ssl/key.pem
# File with certificate for SSL
ssl_certificate_file = /ssl/cert.pem
# Verify client certificate
ssl_verify_client = no
[...]
export LDAP_SSL_PRIVATE_KEY_FILE=/tmp/test.pem
export LDAP_SSL_VERIFY_CLIENT=yes
configomat.sh LDAP_ /etc/kopano/ical.cfg
configomat.sh <PREFIX> <FILE>
# or
configomat.sh <PREFIX> "<FILE1> <FILE2> <FILE3>"
- Add subproject
cd <your-project>
git submodule add https://github.com/alinmear/docker-configomat.git
git commit
- Extend your Dockerfile with theses lines
COPY docker-configomat/configomat.sh /usr/local/bin
RUN chmod +x /usr/local/bin/*
Now you can call the script within your other scripts like described above:
configomat.sh <PREFIX> <FILES>