LoginSignup
10
8

More than 5 years have passed since last update.

docker上でrocketchat+nginxを構築

Posted at

docker上でrocketchat+nginxを構築

rocketchatの構築

docker-composeでrocketchat+mongodb+hubotを構築します。

docker-compose.yml
  rocketchat:
    image: rocketchat/rocket.chat:latest
    restart: unless-stopped
    volumes:
      - ./rocketchat/uploads:/app/uploads
    environment:
      - PORT=3000
      - ROOT_URL=http://localhost:3000/rocketchat
      - MONGO_URL=mongodb://mongo:27017/rocketchat
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local
      - MAIL_URL=smtp://smtp.email
#       - HTTP_PROXY=http://proxy.domain.com
#       - HTTPS_PROXY=http://proxy.domain.com
    depends_on:
      - mongo
    ports:
      - 3000:3000
    labels:
      - "traefik.backend=rocketchat"
      - "traefik.frontend.rule=Host: your.domain.tld"

 mongo:
    image: mongo:3.2
    restart: unless-stopped
    volumes:
     - ./data/db:/data/db
     #- ./data/dump:/dump
    command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1
    labels:
      - "traefik.enable=false"

  # this container's job is just run the command to initialize the replica set.
  # it will run the command and remove himself (it will not stay running)
  mongo-init-replica:
    image: mongo:3.2
    command: 'mongo mongo/rocketchat --eval "rs.initiate({ _id: ''rs0'', members: [ { _id: 0, host: ''localhost:27017'' } ]})"'
    depends_on:
      - mongo

  # hubot, the popular chatbot (add the bot user first and change the password before starting this image)
  hubot:
    image: rocketchat/hubot-rocketchat:latest
    restart: unless-stopped
    environment:
      - ROCKETCHAT_URL=rocketchat:3000
      - ROCKETCHAT_ROOM=GENERAL
      - ROCKETCHAT_USER=bot
      - ROCKETCHAT_PASSWORD=botpassword
      - BOT_NAME=bot
  # you can add more scripts as you'd like here, they need to be installable by npm
      - EXTERNAL_SCRIPTS=hubot-help,hubot-seen,hubot-links,hubot-diagnostics
    depends_on:
      - rocketchat
    labels:
      - "traefik.enable=false"
    volumes:
      - ./scripts:/home/hubot/scripts
  # this is used to expose the hubot port for notifications on the host on port 3001, e.g. for hubot-jenkins-notifier
    ports:
      - 3001:8080

インストール&起動します。

$ docker-compose up

起動したらcurlで確認します。それっぽいhtmlが表示されたらok。

$ curl http://localhost:3000/rocketchat

nginxにリバースプロキシを設定

nginxの構築はこちらの記事を参照。

rocketchatのへのリバースプロキシの設定を追加します。

mysite.template
server {
## 省略 ##
    location /rocketchat/ {
        proxy_pass http://rocketchat:3000/rocketchat/;
        proxy_redirect off;
    }
}

プロキシしているurlのホストがrocketchatとなっていますが、docker上のサービス名と一致しています。こうやって指定することで、アドレス解決はdockerが勝手にやってくれます。

nginxを再起動して設定を反映します。

$ docker-compose restart web

ブラウザからhttp://IPアドレス/rocketchat/にアクセスするとrocketchatの初期設定画面が表示されます。

参考

docker-compose.yml example
https://raw.githubusercontent.com/RocketChat/Rocket.Chat/develop/docker-compose.yml

Configuring SSL Reverse Proxy
https://rocket.chat/docs/installation/manual-installation/configuring-ssl-reverse-proxy/

10
8
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
10
8