-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INITIAL_API_KEY_FILE not working as documented #2212
Comments
Did you set the file env var on the very first Shlink boot up? The initial API key is special, and only set once if no other API keys exist yet. If you started Shlink with the non-file env var and then switched to the file one, Shlink will ignore it. |
Actually, scratch that. I see the problem. This env var is different than the rest, in which it's not read by Shlink at runtime, but in the docker container entry point. See shlink/docker/docker-entrypoint.sh Line 17 in a8e4b2f
That is missing the logic to fall back to the _FILE suffixed env var I'll need to investigate how to support it there. |
In order to fix this I'm introducing a helper command to Shlink that will return the value for any supported env var, but making sure the fallback logic to Then I will use that command in non-php scripts (like the docker entry point) to get the values of env vars, rather than reading env vars directly. That should solve this problem for the |
I have just released Shlink 4.2.2. You should be able to pass |
Seems to be working according the the log, thanks! Initializing database if needed... Success! |
Shlink version
4.2.1
PHP version
4.2.1
How do you serve Shlink
Docker image
Database engine
PostgreSQL
Database version
16.3
Current behavior
When setting up INITIAL_API_KEY_FILE the initial API key is not being created. Using INITIAL_API_KEY works as intended.
As documented in https://shlink.io/documentation/environment-variables/#secret-env-vars
"Starting with Shlink 4.0.0, you can pass any environment variable with the _FILE suffix."
As a side request, if it would be implemented, could web client also use SHLINK_SERVER_API_KEY from the docker secret file?
Expected behavior
INITIAL_API_KEY_FILE loads value from the client and creates initial API key.
Minimum steps to reproduce
Create a docker container with the
shlink:
(...)
secrets:
- source: shlink_api_key
target: /run/secrets/shlink_api_key
environment:
(...)
INITIAL_API_KEY_FILE: /run/secrets/shlink_api_key
The text was updated successfully, but these errors were encountered: