Closed nolith closed 7 years ago
This doesn't seem like a very elegant solution. It's essentially hardcoding a check for BRAIN_PORT_6379_TCP_ADDR
under the assumption that the alias / name, and port number exposed is 'brain', and '6379' respectively.
I don't think the script should depend on Docker. It should be agnostic about its deployment.
I think a better approach would be to set the environment variables in a file (using those exposed by Docker), and source it when running a Hubot container. Something like:
export REDIS_URL=redis://${BRAIN_PORT_6379_TCP_ADDR}:${BRAIN_PORT_6379_TCP_PORT}
You could also take advantage of the hosts defined when linking.
e.g.
export REDIS_URL=redis://brain:6379
I agree that it isn't elegant, I don't like the way docker linking works, but you have to consider that this way you can use the standard node:on-build docker image as starting image for your deploy
FROM node:4-onbuild
ENV PORT 8080
EXPOSE 8080
The redis port number it's hardcoded only in the variable name, when you prepare a Dockerfile you must declare which ports are exposed (6379 in case of the official redis image) but when linked it may be exposed under a different port number.
The assumption of the alias it's just an matter of documentation, supporting Docker means declaring which kind of link are supported and which alias should be used.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This patch uses linking environment variables provided by docker and allow you to run hubot and redis in docker. The redis instance has to be aliased as 'brain'
start a persistent redis brain
docker run --name hubot_brain -d redis redis-server --appendonly yes
then start your hubot image
docker run -d --link hubot_brain:brain your_hubot_image