From 7d209b96e5feb6dc1140f35e353fceb14d6750ca Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 2 Mar 2014 12:18:51 -0800 Subject: [PATCH] hubot: Add a hubot image I had to instal Git to avoid a: GET https://registry.npmjs.org/scoped-http-client GET https://registry.npmjs.org/async ERR! not found: git npm ERR! ERR! Failed using git. This is most likely not a problem with npm itself. Please check if you have git installed and in your PATH. Linux 3.13.0 command "/usr/bin/node" "/usr/bin/npm" "install" cwd /hubot node -v v0.10.21 1.3.11 ENOGIT error during the 'npm install'. Other than that, this is fairly straightforward, although I wish that the script dependencies were handled automatically :p. Docker doesn't let you modify /etc/hosts at the moment [1]. If you need to add custom DNS (because your target IRC server doesn't resolve automatically), you can use dnsmasq [2]. I added something like this to the tail of my hubot/Dockerfile.template: RUN emerge -v dnsmasq RUN rc-update add dnsmasq default RUN echo 'address="/irc.example.net/192.168.0.2"' >> /etc/dnsmasq.conf RUN echo 'nameserver 192.168.0.1' >> /etc/resolv.dnsmasq.conf RUN echo 'resolv-file=/etc/resolv.dnsmasq.conf' >> /etc/dnsmasq.conf RUN echo 'listen-address=127.0.0.1' >> /etc/dnsmasq.conf RUN sed -i 's/need localmount net$/use localmount net/' /etc/init.d/dnsmasq And fired up the container with: docker run ... --dns 127.0.0.1 wking/hubot /bin/bash # rc default # cd hubot # REDISCLOUD_URL="${REDIS_PORT}" exec bin/hubot --name "${HUBOT_IRC_NICK:-hubot}" -a irc [1]: https://github.com/dotcloud/docker/issues/2267 [2]: https://github.com/dotcloud/docker/issues/1951#issuecomment-24960347 --- hubot/Dockerfile.template | 60 +++++++++++++++++++++++++++++++++++++++ hubot/README.md | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 hubot/Dockerfile.template create mode 100644 hubot/README.md diff --git a/hubot/Dockerfile.template b/hubot/Dockerfile.template new file mode 100644 index 0000000..36b9bd8 --- /dev/null +++ b/hubot/Dockerfile.template @@ -0,0 +1,60 @@ +# Copyright (C) 2014 W. Trevor King +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +FROM ${NAMESPACE}/gentoo-node:${TAG} +MAINTAINER ${MAINTAINER} +#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"] +RUN emerge -v dev-vcs/git +RUN eselect news read new +RUN npm install -g hubot coffee-script +RUN hubot --create hubot +RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "redis": "0.8.4",/' hubot/package.json +RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "hubot-irc": "0.2.1",/' hubot/package.json + +RUN sed -i 's/\]$/,\n "github-commit-link.coffee"]/' hubot/hubot-scripts.json +RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\1 "githubot": "0.4.x",/' hubot/package.json + +RUN sed -i 's/\]$/,\n "github-commits.coffee"]/' hubot/hubot-scripts.json +RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "url": "",/' hubot/package.json +RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "querystring": "",/' hubot/package.json +RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "gitio": "1.0.1",/' hubot/package.json + +RUN sed -i 's/\]$/,\n "github-issue-link.coffee"]/' hubot/hubot-scripts.json +#RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "githubot": "0.4.x",/' hubot/package.json + +RUN sed -i 's/\]$/,\n "github-issues.coffee"]/' hubot/hubot-scripts.json +RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "underscore": "1.3.3",/' hubot/package.json +RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "underscore.string": "2.1.1",/' hubot/package.json +#RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "githubot": "0.4.x",/' hubot/package.json + +RUN sed -i 's/\]$/,\n "github-pull-request-notifier.coffee"]/' hubot/hubot-scripts.json +#RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "url": "",/' hubot/package.json +#RUN sed -i 's/\([[:space:]]*\)\("dependencies": {\)/\1\2\n\1 "querystring": "",/' hubot/package.json + +RUN cd hubot && npm install + +# Container networking happens automatically +RUN sed -i 's/need net$/use net/' /etc/init.d/* + +CMD cd hubot && REDISCLOUD_URL="${REDIS_PORT}" exec bin/hubot --name "${HUBOT_IRC_NICK:-hubot}" -a irc diff --git a/hubot/README.md b/hubot/README.md new file mode 100644 index 0000000..131a3dd --- /dev/null +++ b/hubot/README.md @@ -0,0 +1,49 @@ +This image has a custom [hubot][] with the [hubot-irc][] adapter and a +number of [scripts][] installed out of the box: + +* [github-commit-link][] +* [github-commits][] +* [github-issue-link][] +* [github-issues][] +* [github-pull-request-notifier][] + +It's also easy to [write your own scripts][scripting]. + +Run this [hubot][] image with: + + $ docker run -d --name hubot-0 \ + > -e HUBOT_IRC_NICK="myhubot" \ + > -e HUBOT_IRC_USESSL="true" \ + > -e HUBOT_IRC_SERVER="irc.freenode.net" \ + > -e HUBOT_IRC_PORT="6697" \ + > -e HUBOT_IRC_ROOMS="#my-channel, #my-other-channel" \ + > -e HUBOT_IRC_UNFLOOD="200" \ + > -e HUBOT_GITHUB_USER="github" \ + > -e HUBOT_GITHUB_REPO="github/hubot" \ + > --link redis-0:redis \ + > wking/hubot + +If your IRC server requires a server-wide password, you can set +`HUBOT_IRC_PASSWORD`. + +The [link][] to `redis-0` is for the default [redis-brain][] script. +You should be able to link to any Redis server, but this Dockerfile +repository already [provides one][redis]. + +If you want the GitHub scripts to be able to access private +repositories (e.g. to link to private issues or commits), you need to +set `HUBOT_GITHUB_TOKEN` to your [OAuth token][token]. + +[hubot]: https://github.com/github/hubot +[hubot-irc]: https://github.com/nandub/hubot-irc +[scripts]: https://github.com/github/hubot-scripts/tree/master/src/scripts +[github-commit-link]: https://github.com/github/hubot-scripts/blob/master/src/scripts/github-commit-link.coffee +[github-commits]: https://github.com/github/hubot-scripts/blob/master/src/scripts/github-commits.coffee +[github-issue-link]: https://github.com/github/hubot-scripts/blob/master/src/scripts/github-issue-link.coffee +[github-issues]: https://github.com/github/hubot-scripts/blob/master/src/scripts/github-issues.coffee +[github-pull-request-notifier]: https://github.com/github/hubot-scripts/blob/master/src/scripts/github-pull-request-notifier.coffee +[scripting]: https://github.com/github/hubot/blob/master/docs/scripting.md +[link]: http://docs.docker.io/en/latest/use/port_redirection/#linking-a-container +[redis-brain]: https://github.com/github/hubot-scripts/blob/master/src/scripts/redis-brain.coffee +[redis]: ../redis/ +[token]: https://help.github.com/articles/creating-an-access-token-for-command-line-use -- 2.26.2