https://github.com/gatblau/boot
merge environment variables in static configuration files before launching docker containers
https://github.com/gatblau/boot
boot configuration-files docker-image environment-variables merge
Last synced: 3 months ago
JSON representation
merge environment variables in static configuration files before launching docker containers
- Host: GitHub
- URL: https://github.com/gatblau/boot
- Owner: gatblau
- License: apache-2.0
- Created: 2020-09-09T16:23:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-03T09:24:46.000Z (over 4 years ago)
- Last Synced: 2023-03-02T23:02:46.240Z (about 2 years ago)
- Topics: boot, configuration-files, docker-image, environment-variables, merge
- Language: Go
- Homepage:
- Size: 14 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# BOOT
*BOOT* is a utility that merges environment variables into (configuration) files. It is designed to pass environment variables to applications with static configuration files running inside Docker containers.
It is an alternative to overlaying the configuration file on the container on start up.
Simply:
- add environment variable placeholders into the files
- export environment variables with the required values
- call *boot* passing the file names to be updated
- launch your app## Getting Started
1. Download the *boot* utility platform specific versions from [here](./build).
2. Create a bootstrap file to merge the variables and launch the app like follows:
```shell script
# start.sh
/app/boot /app/conf1 /app/conf2 ...
exec "$@"
```3. Copy boot and the configuration with placehoslders to the docker image
4. Call the bootstrap script from the CMD line (mosquitto mqtt broker example):
```dockerfile
CMD ["sh", "/app/start.sh", "/app/mosquitto", "-c", "/app/mosquitto.conf"]
```## Merging Vars
given the following *test.cfg* config file:
```shell script
cfg1=${ENV_VAR_1}
# ADS2 is a default value
cfg2=${ENV_VAR_2:ASD2}
cfg3=${ENV_VAR_3}
cfg4=${ENV_VAR_4}
```on the command line run:
```shell script
# export environment variables
# note no variable ENV_VAR_2 is defined
export ENV_VAR_1=AAA
export ENV_VAR_3=CCC
export ENV_VAR_4=DDD# merge variables in the config file
./boot test.cfg
```check the contents of the file:
```shell script
cfg1=AAA
# merged default
cfg2=ASD2
cfg3=CCC
cfg4=DDD
```**NOTE**: using "PWD" as environemtn variable is not allowed as it can retrieve the path of the current process in some OS.
If no variables are exported the execution will fail.