Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SERVEO 讓你用 Docker 開發 chatbot 也能過的去 @ COSCUP 2019

SERVEO 讓你用 Docker 開發 chatbot 也能過的去 @ COSCUP 2019

初學者在準備要來開發一個聊天機器人的程式時,通常會遇到的一個問題就是,各大平台幾乎都是要求 https 連線,這在愛用 Docker 作為開發環境的我更是一大困難!在 LINE Developers Document 上面建議使用 ngrok,但是 ngrok 免費版的限制也是非常多,特別是每次重開 ngrok 以後,就需要更換一次聊天機器人的後端網址,真的是非常的不方便…後來找到了 serveo 這個服務,發現了他的好用之處後,就順手做了 Docker Image 讓它更方便在 Docker 環境中使用,然後還額外做了 server self-host 的 Docker Image,這場議程就是來教大家怎麼在 Docker 中使用這兩個東西。

戴均民

August 18, 2019
Tweet

More Decks by 戴均民

Other Decks in Programming

Transcript

  1. SERVEO SERVEO 讓你⽤ 讓你⽤ Docker Docker 開發 開發 chatbot 也能過的去

    chatbot 也能過的去 簡報: 簡報: https://lihi1.cc/hZ1pK https://lihi1.cc/hZ1pK 1 1
  2. Who am I? Who am I? 戴均⺠ 戴均⺠ 現職 現職

    微程式資訊 微程式資訊 後端⼯程師 後端⼯程師   taichunmin taichunmin 2 2
  3. 4 4

  4. 8 8

  5. 9 9

  6. SERVEO 使⽤教學 SERVEO 使⽤教學 # 基礎用法 # 基礎用法 ssh -R

    80:localhost:3000 serveo.net ssh -R 80:localhost:3000 serveo.net # 存取不在本機上的 server # 存取不在本機上的 server ssh -R 80:example.com:80 serveo.net ssh -R 80:example.com:80 serveo.net # 指定子網域 # 指定子網域 ssh -R incubo:80:localhost:8888 serveo.net ssh -R incubo:80:localhost:8888 serveo.net # 避免 ssh 逾時 # 避免 ssh 逾時 ssh -o ServerAliveInterval=60 -R 80:localhost:8888 serveo ssh -o ServerAliveInterval=60 -R 80:localhost:8888 serveo # 斷線自動重連 # 斷線自動重連 autossh -M 0 -R 80:localhost:8888 serveo.net autossh -M 0 -R 80:localhost:8888 serveo.net 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 10 10
  7. docker-compose.yml docker-compose.yml version version: : '2' '2' services services: :

    serveo serveo: : image image: : taichunmin/serveo taichunmin/serveo: :latest latest tty tty: : true true stdin_open stdin_open: : true true # see https://serveo.net/ for more options # see https://serveo.net/ for more options command command: : > > autossh -M 0 autossh -M 0 -o ServerAliveInterval=60 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o StrictHostKeyChecking=no -R 80:nginx:80 -R 80:nginx:80 serveo.net serveo.net nginx nginx: : image image: : nginx nginx: :latest latest 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 15 15
  8. 在 Docker 裡⾯ 在 Docker 裡⾯ 要把 要把本機 本機的服務 的服務

    轉成 HTTPS 也沒問題 轉成 HTTPS 也沒問題 17 17
  9. Windows / macOS Windows / macOS version version: : '2'

    '2' services services: : serveo serveo: : image image: : taichunmin/serveo taichunmin/serveo: :latest latest tty tty: : true true stdin_open stdin_open: : true true # Docker for Windows / macOS # Docker for Windows / macOS command command: : > > autossh -M 0 autossh -M 0 -o ServerAliveInterval=60 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o StrictHostKeyChecking=no -R 80:host.docker.internal:3000 -R 80:host.docker.internal:3000 serveo.net serveo.net 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 18 18
  10. Linux Linux version version: : '2' '2' services services: :

    serveo serveo: : image image: : taichunmin/serveo taichunmin/serveo: :latest latest tty tty: : true true stdin_open stdin_open: : true true # Docker for Linux # Docker for Linux command command: : > > HOST_DOMAIN=`ip route|awk '/default/ { print $3 }'` HOST_DOMAIN=`ip route|awk '/default/ { print $3 }'` autossh -M 0 autossh -M 0 -o ServerAliveInterval=60 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o StrictHostKeyChecking=no -R 80:$HOST_DOMAIN:3000 -R 80:$HOST_DOMAIN:3000 serveo.net serveo.net 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 19 19
  11. Any Question? Any Question? taichunmin/serveo taichunmin/serveo taichunmin/serveo-server taichunmin/serveo-server stars stars

    60 60 docker stars docker stars 2 2 stars stars 24 24 docker stars docker stars 2 2 32 32