LoginSignup
5
5

More than 5 years have passed since last update.

Docker でコンテナを立ち上げた時に Hubot を起動したい

Posted at

Hubot 自体を GitHub においておくとして、それを持ってきて Docker コンテナ上で動かす時、コンテナを立ち上げた時に自動で Hubot の起動もできたら、極少数の作業で環境が整う。

Hubot のリポジトリに Dockerfile をつくる

Hubot の動作に必要なイメージは以前の記事で作ったものを使う。

Dockerfile
FROM your/hubot
MAINTAINER keithyokoma

# env set up 1
ENV HOME /home/docker
ENV HUBOT_SLACK_TOKEN token
RUN mkdir /home/docker/hubot
ADD . /home/docker/hubot

# install hubot dependencies
RUN cd /home/docker/hubot && npm install

# start hubot on run docker container
CMD cd /home/docker/hubot; bin/hubot --adapter slack

コンテナを起動する

GitHub のリポジトリを clone したら、以下のコマンドでコンテナを起動する。そうすると、Dockerfile の最後の行の CMD にあるコマンドが実行され、Hubot が立ち上がる。

$ docker run -d hubot_image_name
5
5
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
5
5