2018年2月21日水曜日

Windows10でRocket.chatとHubotのDockerを動かす

■前提条件
Docker導入済。
docker-composeコマンドが使えること。

■手順
1.Docker用ディレクトリを作成する。
c:>mkdir C:\docker\rocket-chat

2.Dockerレシピを作成
ここからファイルをダウンロードして、1で作成したディレクトリに保存。
以下のように内容を修正する。
version: '2'

services:
  rocketchat:
    image: rocketchat/rocket.chat:latest
    restart: unless-stopped
    volumes:
      - ./uploads:/app/uploads
    environment:
      - PORT=3000
      - ROOT_URL=http://localhost:3000
      - 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:/data         ## ←こうしないとPermissionのエラーで起動しない ##
#     #- ./data/dump:/dump
    command: mongod --smallfiles --oplogSize 128 --replSet rs0
    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=localhost:3000    ## rocketchatサーバ名
      - ROCKETCHAT_ROOM=GENERAL          ## 参加チャネル名
      - ROCKETCHAT_USER=bot              ## rocketchatログインユーザ名
      - ROCKETCHAT_PASSWORD=botpassword  ## rocketchatログインパスワード
      - BOT_NAME=bot                     ## rocketchatボット名
  # 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

  #traefik:
  #  image: traefik:latest
  #  restart: unless-stopped
  #  command: traefik --docker --acme=true --acme.domains='your.domain.tld' --acme.email='your@email.tld' --acme.entrypoint=https --acme.storagefile=acme.json --defaultentrypoints=http --defaultentrypoints=https --entryPoints='Name:http Address::80 Redirect.EntryPoint:https' --entryPoints='Name:https Address::443 TLS.Certificates:'
  #  ports:
  #    - 80:80
  #    - 443:443
  #  volumes:
  #    - /var/run/docker.sock:/var/run/docker.sock

3.コンテナ作成
以下のコマンドを実行するとコンテナが作成される。初回はイメージダウンロードで少し時間がかかる。
プロセスのStateがUpになっているとOK。2つ目のやつは1回きりコマンドが実行されればOKなので無視。
C:\docker\rocket-chat>docker-compose up -d
Creating rocketchat_mongo-init-replica_1 ... done
Creating rocketchat_rocketchat_1         ... done
Creating rocketchat_rocketchat_1         ...
Creating rocketchat_hubot_1              ... done

C:\docker\rocket-chat>docker-compose ps
             Name                            Command               State            Ports
--------------------------------------------------------------------------------------------------
rocketchat_hubot_1                /bin/sh -c node -e "consol ...   Up       0.0.0.0:3001->8080/tcp
rocketchat_mongo-init-replica_1   docker-entrypoint.sh mongo ...   Exit 0          
rocketchat_mongo_1                docker-entrypoint.sh mongo ...   Up       27017/tcp
rocketchat_rocketchat_1           node main.js                     Up       0.0.0.0:3000->3000/tcp

4.Rocket.Chatに接続
http://localhost:3000にブラウザでアクセスするとログイン画面が表示される。


5.Hubot用のユーザ作成
新規ユーザを作成し、2の設定ファイルに指定したHubotのユーザアカウントを作成する。
Rollはbotを選ぶこと。
作成したらコンテナを再起動する。
C:\docker\rocket-chat>docker-compose restart
Restarting rocketchat_mongo-init-replica_1 ... done
Restarting rocketchat_hubot_1              ... done
Restarting rocketchat_rocketchat_1         ... done
Restarting rocketchat_mongo_1              ... done


■その他
何度も使ったコマンドたち。

・docker-compose stop
コンテナを全て停止

・docker-compose start
コンテナを全て開始

・docker-compose rm -v
停止しているコンテナを削除

・docker ps
動いているコンテナの一覧を表示

・docker stop "CONTAINER ID"
コンテナIDを指定して停止(特定のコンテナだけを削除したい時に使用)

2018年2月8日木曜日

【UWP】"uwp the name does not exist in the namespace"エラーへの対応

UWPの画面で「」みたいなことを書いたら、Modelで定義しているNamespaceにHogehogeなんてねーよってエラーが出ることがある。
よくわかんないけど以下の手順で解決。

1.一回エラーになってるところを削除してビルド
2.ビルドが通ったらソースを戻すとあら不思議エラーが消えちゃう

なおModelの定義は、最初のPageタグ内の属性で定義する。
xmlns:Model="using:Namespage"