docker-vernemq
docker-vernemq copied to clipboard
Added env API_KEY to add api key at runtime
Can be used in docker-compose.yml:
... environment: - API_KEY=MyApiKey
@dvdred thanks... can you explain why this is needed? is it a backward compatible addition? (if yes, I'll merge this)
hello, sorry for the delay! the change was useful to me because I am using vernemq on docker swarm and I need to set an api key at runtime taking it's value froma a docker env. I have not found any other way.
I'm also looking for this feature. Right now my startup script has to wait for the nodes to be reachable. Then I can try to add the key using the vmq-admin command. I have trouble getting this to work flawlessly 100% of the time. Being able to set the key using a environment variable would be awesome!
You can do it by creating your own image derived from vernemq and override some directive
COPY commands.sh /scripts/commands.sh
RUN ["chmod", "+x", "/scripts/commands.sh"]
ENTRYPOINT ["/scripts/commands.sh"]
then you can start VerneMQ and start a command for building a key
#!/bin/bash
echo "Starting Hub"
echo "##############################################"
echo "$API_KEY"
start_vernemq &
/bin/sh -c "sleep 30 ; vmq-admin api-key add key=$API_KEY"
fg %1
$API_KEY
is an env var. Just add it to your compose file.
Result in shell after 30 sec
root@a8396e7ef459:/node/app# vmq-admin api-key show
+----------------------------------+
| Key |
+----------------------------------+
| YOURAPIKEY |
+----------------------------------+
root@a8396e7ef459:/node/app#
Can this be added to standard env keys?
Can this be added to standard env keys?
@Ashtonian could be done, yes. by adding a mapping to the vmq_server
schema file. (and some additional handling at boot time to add the API key to a config table as well)
:point_right: Thank you for supporting VerneMQ: https://github.com/sponsors/vernemq :point_right: Using the binary VerneMQ packages commercially (.deb/.rpm/Docker) requires a paid subscription.
Closing, as we merged https://github.com/vernemq/docker-vernemq/pull/369. Thank you again to everyone who helped out here!