There is a common command line tool on most Unix systems that can handle base64 encoding and decoding very simply and it would be pretty straightforward to use it in the startup script in the docker image to do what you like. The command is unsurprisingly
base64. A very simple example would be something like…
$ echo "hi" | base64 | base64 -d
You pipe “hi” to the
base64 command which encodes it and then pipes the encoded text to
base64 -d which decodes it so you end up with “hi” again.
Using an environment variable in that and saving the decoded text in a config file you could use could look like…
How you’d populate the config environment variable on the deployment side…
CONFIG=$(echo "my config here" | base64)
Then in the Docker startup script, you’d do something like…
echo $CONFIG | base64 -d > /path/to/config.hcl
If any part isn’t clear, please feel free to ask any questions.
Hope this helps.