LoginSignup
0
0

More than 5 years have passed since last update.

hubot-slackのためのDockerfile (debian)

Posted at

ディレクトリ詳細

hubot-slack
  |
  ├──scripts    # このディレクトリ以下にhubotの応答用スクリプトを用意
  ├──tools      # このディレクトリ以下に応答内容に応じて実行されるスクリプトを用意
  └──Dockerfile # docker buildで使用 

Dockerfile

FROM node:latest

MAINTAINER XXXX <xxxxx@xxx.com>

# package update
RUN apt-get update && \
    apt-get -y install -y git-core redis-server vim

RUN adduser --disabled-password --gecos "" hubot && \
    chown -R hubot:hubot /home/hubot  && \
    echo "hubot ALL=(ALL)       ALL" >> /etc/sudoers && \
    mkdir /root/packages && \
    cd /root/packages && \
    wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && \
    chmod +x jq-linux64 && \
    cp -p jq-linux64 /usr/bin/jq

RUN npm install -g coffeelint
RUN npm install -g yo generator-hubot
RUN npm install hubot-slack hubot-proxy-loader --save

USER hubot
WORKDIR /home/hubot
RUN mkdir test && \
    mkdir test/tools && \
    cd test && \
    yo hubot --owner hoge --name testbot --description "hubot for hoge" --adapter slack && \
    jq ' .-["hubot-heroku-keepalive","hubot-pugme","hubot-shipit"]' external-scripts.json > new-external-scripts.json && \
    jq ".[$(jq -s '.[] | length' new-external-scripts.json)]|= .+\"hubot-proxy-loader\"" new-external-scripts.json > new2-external-scripts.json && \
    mv new2-external-scripts.json external-scripts.json && rm -f new-external-scripts.json && rm -f hubot-scripts.json

COPY tools/ test/tools
COPY scripts/ test/scripts

ENV HUBOT_SLACK_TOKEN xxxx-123123-234434ssssss
ENV HUBOT_SLACK_CHANNELMODE whitelist
ENV HUBOT_SLACK_CHANNELS temporalchatroom

WORKDIR /home/hubot/test
CMD bin/hubot --adapter slack

LABEL version="0.0.1"
  • jqを新たにインストール
  • jqでexternal-scripts.jsonを編集してアドオンを必要に応じて取捨選択
  • slackのTokenはslack上で発行したものを書く
  • COPYで必要なものをコピーしてくる

docker buildとdocker run

docker build -t your-repo-name/image-name:0.0.1 --force-rm=true --no-cache=true .
docker run --name testbot -d -t your-repo-name/image-name:0.0.1

注意点

  • コピーするcoffeeスクリプトにシンタックスエラーがあると、docker run後にコンテナがExited(127)などのステータスになり動かない。
  • WORKDIRで決めたディレクトリより上の階層をRUNの中で言及するとbuild時にエラーになり怒られる。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0