feat: populate env vars from secret files in docker entrypoint #1512
25
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📚 Description
Docker swarm does only support secrets as files. Nuxt reads env vars automatically and populates the typed runtimeConfig with it. At the moment this is handled in application code, which is repetitive and not deployment agnostic. It also causes issue in frontend only mode, where developers need to setup files.
See an example of current handling in tusd utils
This PR moves this handling out of application code to the docker entrypoint.
All env vars with suffix _SECRETSFILE populate there suffix-less version now with the secret inside the file.
This means, we can configure a docker secret /run/secret/my_secret=super-secret, configure environment variable NUXT_MY_SECRET_SECRETSFILE=/run/secret/my_secret and access runtimeConfig.mySecret=super-secret in application code.
I've not cleaned up the the existing code yet, but I run across this in context of oauth2 config
📝 Checklist