Giter Site home page Giter Site logo

docker-alpinehubot's Introduction

hearstat/alpine-hubot

Hubot running on Alpine with the Hipchat Adapter.

Build Info

NODE

  • NodeJS: 4.12
  • NPM: 2.24.9

Default Scripts

Installed Packages

  • bash
  • supervisor
  • nodejs
  • redis
  • build-base
  • gc
  • g++
  • gcc-objc
  • libtool
  • libc6-compat
  • make
  • expat
  • expat-dev
  • python
  • wget
  • gnupg
  • tar
  • git
  • zip
  • curl
  • wget

Suggested Mounts

Mount the redis directory to avoid data reset on container replacement

  • /var/lib/redis

Mount the config directory to manage credentials/settings outside of container

  • /opt/hubot/config

Mount the scripts directory to manage any non-npm installs/simple scripts

  • /opt/hubot/scripts

Mount the external-scripts for control

  • /opt/hubot/external-scripts.json

Usage

You have a few options in how to utilize this container

Basic Start

docker run -v -e HUBOT_HIPCHAT_JID=jid \
  -e HUBOT_HIPCHAT_PASSWORD=secret \
  -e HUBOT_AUTH_ADMIN=admin \
  -d hearstat/alpine-hubot

Configuration File Start

docker run -v /path/to/hubot.conf:/opt/hubot/config/hubot.conf -d hearstat/alpine-hubot

Full Feature Start

docker run -v /path/to/hubot.conf:/opt/hubot/config/hubot.conf \
-v /path/to/redis/save:/var/lib/redis \
-v /path/to/external-scripts.json:/opt/hubot/external-scripts.json \
-d hearstat/alpine-hubot

Dev Mode Start

I've setup this bot to be able to switch back and forth from Hipchat to Shell via startup commands. This is how to get into "Dev Mode" or enable the shell adapter.

docker run -d hearstat/alpine-hubot /usr/bin/devmode

then just do the following to connect to the container at the shell level

docker exec -it $container_name bash

then once in run the following

./bin/hubot

Then you can interact with hubot at the shell level

Node-Inspector

Run:

docker run -d -p 8123:8123 -p 5858:5858 --name=devbot hearstat/alpine-hubot devmode
docker exec -it devbot bash
coffee --nodejs --debug $(which hubot)

In Chrome navigatate to http://:8123/?ws=:8123&port=5858 For Mac users "docker IP" can be found in Kitematic. Example: http://192.168.99.100:8123/?ws=192.168.99.100:8123&port=5858

NOTE: You should end up in a hubot REPL, if you end up in a coffee REPL you did something wrong. To exit:

coffee> process.exit()

NOTE: node-inspector currently only works in Chrome.

To set a breakpoint in coffeescript you will want to open the code in the /opt/hubot/node_modules/ directory and add at the appropriate line:

debugger

You may want to mount a directory locally so you can use your local editor. For Mac this will need to be in your /Users/ dir To do this consider:

mkdir -p ~/node_modules
docker run -d -p 8123:8123 -p 5858:5858 -v /Users/<username>/node_modules:/opt/hubot/node_modules --name=devbot hearstat/alpine-hubot devmode

Prod Mode Start

To switch back to hipchat or "Prod Mode" do the following

docker exec $container_name /usr/bin/prodmode

or just run a new container

Run Time Help

Since this container comes with a bot reload option, edit the external-scripts.json as needed and run the following

docker exec $container_name python script-install.py

Note: you can just restart the container, it will re-run the same script before loading the bot.

Then in chat tell hubot to reload (my default is thebot)

@hubot reload

Building

To build the image, do the following

docker build github.com/hearstat/docker-alpinehubot

A prebuilt container is available in the docker index.

docker pull hearstat/alpine-hubot

Template files

Hubot.Conf

Lives at /opt/hubot/config and is sourced at run time.

Add all environment variables needed to conf file. See script repos for specific settings available.

The baseline config file in container only has ADAPTER/HUBOT_NAME set.

## Bot Settings
export HUBOT_NAME='hubot' # what hubot listens to

## Comma separated list of users who administer Hubot Auth
export HUBOT_AUTH_ADMIN="YourName"

## Hipchat adapter settings

# Credentials
export HUBOT_HIPCHAT_JID="[email protected]"
export HUBOT_HIPCHAT_PASSWORD="SuperSecretPassword"

# Actual Rooms to join (JIDs)
export HUBOT_HIPCHAT_ROOMS="[email protected]"

# Set true/false to auto join rooms when mentioned/invited (true/false)
export HUBOT_HIPCHAT_JOIN_ROOMS_ON_INVITE="true"

# Explicitly refuse to join specified rooms (JIDs)
export HUBOT_HIPCHAT_ROOMS_BLACKLIST=""

# Auto reconnect attempt (true/false)
export HUBOT_HIPCHAT_RECONNECT="true"

# Set true/false for bot to join public rooms.
export HUBOT_HIPCHAT_JOIN_PUBLIC_ROOMS="false"

external-scripts.json

The embedded script-install.py utilizes the external-scripts.json for it's install items, I did this to simplify the process. You already have to add everything to the file regardless, so use it to install from.

[
  "hubot-diagnostics",
  "hubot-help",
  "hubot-google-images",
  "hubot-pugme",
  "hubot-maps",
  "hubot-redis-brain",
  "hubot-rules",
  "hubot-shipit",
  "hubot-pager-me",
  "hubot-plusplus",
  "hubot-reload-scripts",
  "hubot-leankit"
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.