I'm trying to set a public key as environment variable inside my docker-compose.yaml file.
I understand we have 2 different syntax we can use (can't use both at same time):
One is a YAML mapping, which uses the syntax key: value
:
environment:
key: value
key2: value2
// And this is how we Muliline
publicKey: |-
-----BEGIN PUBLIC KEY-----
UAdhusaudu89Ajdsdoskdosadk*(Sd98798da
kaosdkOKdoksaoKDOaksdo98d7868sadajidas
And we also have the YAML list
syntax, which uses the syntax var = value
:
environment:
key=value
But how may I successfully multiline using YAML list syntax?
I need to get the line breaks (\n) too.
When I try to read the environment variable I get a string where instead of having line breaks (/n) I get a single whitespace.
I get:
-----BEGIN PUBLIC KEY----- KOSKODKSOAKD DOKSODKSAOD...
what I actually need:
-----BEGIN PUBLIC KEY-----\nKOSKODKSOAKD\nDOKSODKSAOD...
(note the /n).
Why I need this?
Without it, the public key verification/validation will fail.
Now I have a function that runs through the string and manually adds the line breakers, but it ain't pretty, if I could make it work from the docker-compose file it would be much better.