# <span style="color: cyan">SERVEO</span>
### 讓你用 <span style="color: lime">Docker</span> 開發
### chatbot 也能過的去
<small style="margin-top: 10rem">簡報: `https://lihi1.com/WcqIf`</small>
---
## Who am I?
<table class="about-me">
<tr>
<td><img src="https://www.gravatar.com/avatar/8d9b432d861e4ac0e40954a800ae90a1?s=2048" class="avatar"></td>
<td>
<ul>
<li>戴均民</li>
<li>現職 <span style="color: #e2231a">微程式資訊</span></li>
<li>後端工程師</li>
<li><a href="https://github.com/taichunmin/" target="_blank"><i class="fa fa-fw fa-github"></i>taichunmin</a></li>
</ul>
</td>
</tr>
</table>
---
<table class="about-me">
<tr>
<td><img src="https://i.imgur.com/VJac4FR.png" style="height: 600px"></td>
<td>
<h4>功能</h4>
<ul>
<li>站點查詢</li>
<li>行程規劃</li>
<li>最愛場站</li>
</ul>
<img src="https://i.imgur.com/BCviB4l.png" style="height: 250px; display: block; max-height: none; max-width: none;">
</td>
</tr>
</table>
---
#### 相信不少人都用過 NGROK

---

---
## 隨機 DOMAIN

---
## 一次只能開一個

---
## 40 個連線 / 分

---

---

---
## SERVEO 使用教學
```bash=
# 基礎用法
ssh -R 80:localhost:3000 serveo.net
# 存取不在本機上的 server
ssh -R 80:example.com:80 serveo.net
# 指定子網域
ssh -R incubo:80:localhost:8888 serveo.net
# 避免 ssh 逾時
ssh -o ServerAliveInterval=60 -R 80:localhost:8888 serveo.net
# 斷線自動重連
autossh -M 0 -R 80:localhost:8888 serveo.net
```
---
## 因為我很常使用
## Docker 輔助開發
---
## 所以我就幫 SERVEO
## 做了 <span style="color: lime">Docker Image</span>
---
## <a href="https://hub.docker.com/r/taichunmin/serveo" target="_blank">taichunmin/serveo</a>

---
## 要把<span style="color: lime">其他容器</span>的服務
## 轉成 HTTPS 很簡單
---
### `docker-compose.yml`
```yaml=
version: '2'
services:
serveo:
image: taichunmin/serveo:latest
tty: true
stdin_open: true
# see https://serveo.net/ for more options
command: >
autossh -M 0
-o ServerAliveInterval=60
-o ServerAliveCountMax=3
-o ExitOnForwardFailure=yes
-o StrictHostKeyChecking=no
-R 80:nginx:80
serveo.net
nginx:
image: nginx:latest
```
---
# DEMO 1
<https://github.com/taichunmin/coscup-2019-demo>
---
## 在 Docker 裡面
## 要把<span style="color: lime">本機</span>的服務
## 轉成 HTTPS 也沒問題
---
## Windows / macOS
```yaml=
version: '2'
services:
serveo:
image: taichunmin/serveo:latest
tty: true
stdin_open: true
# Docker for Windows / macOS
command: >
autossh -M 0
-o ServerAliveInterval=60
-o ServerAliveCountMax=3
-o ExitOnForwardFailure=yes
-o StrictHostKeyChecking=no
-R 80:host.docker.internal:3000
serveo.net
```
---
## Linux
```yaml=
version: '2'
services:
serveo:
image: taichunmin/serveo:latest
tty: true
stdin_open: true
# Docker for Linux
command: >
HOST_DOMAIN=`ip route|awk '/default/ { print $3 }'`
autossh -M 0
-o ServerAliveInterval=60
-o ServerAliveCountMax=3
-o ExitOnForwardFailure=yes
-o StrictHostKeyChecking=no
-R 80:$HOST_DOMAIN:3000
serveo.net
```
---
# DEMO 2
<https://github.com/taichunmin/coscup-2019-demo>
---
# SERVEO
## 還可以<span style="color: lime">自己架設</span>伺服器
---
## 所以我幫伺服器版
## 也做了 <span style="color: lime">Docker Image</span>
---
## <a href="https://hub.docker.com/r/taichunmin/serveo-server" target="_blank">taichunmin/serveo-server</a>

---
## 準備<span style="color: lime">一台主機</span>
---
## DigitalOcean
* 開一台最便宜的機器
* 5 鎂 / 月
* 1GB RAM
* 1 vCPU
* 網路流量 1TB
* 25GB SSD
* [用這邀請連結註冊有 50 鎂的免費額度](https://m.do.co/c/81327b020798)
---
## 以下範例使用
## Ubuntu 18.04.3 LTS
---
## 安裝 Docker
```bash=
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
```
---
## 安裝 Docker Compose
```bash=
export DOCKER_VERSION=$(curl -sL https://api.github.com/repos/docker/compose/releases/latest | grep tag_name | cut -d'"' -f 4)
sudo curl -L https://github.com/docker/compose/releases/download/${DOCKER_VERSION}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
```
---
## git clone
```bash=
git clone https://github.com/taichunmin/docker-serveo-server.git
```
---
## 準備好你的 <span style="color: cyan">DOMAIN</span>
---
## Dot TK
免費一年 `.tk` 網域
<http://www.dot.tk/en/index.html?lang=en>
---
## 準備一個 <span style="color: orange">HTTPS 憑證</span>
---
## 將 DNS 代管至 Cloudflare
---
# DEMO 3
<https://github.com/taichunmin/coscup-2019-demo>
---
## 實作時間
<table class="table-shield" style="margin-top: 10rem">
<tr>
<th>taichunmin/serveo</td>
<td>
<a href="https://github.com/taichunmin/docker-serveo" target="_blank">
<img class="img-shield" src="https://img.shields.io/github/stars/taichunmin/docker-serveo.svg?logo=github">
</a>
</td>
<td>
<a href="https://hub.docker.com/r/taichunmin/serveo" target="_blank">
<img class="img-shield" src="https://img.shields.io/docker/stars/taichunmin/serveo.svg?logo=docker">
</a>
</td>
</tr>
<tr>
<th>taichunmin/serveo-server</td>
<td>
<a href="https://github.com/taichunmin/docker-serveo-server" target="_blank">
<img class="img-shield" src="https://img.shields.io/github/stars/taichunmin/docker-serveo-server.svg?logo=github">
</a>
</td>
<td>
<a href="https://hub.docker.com/r/taichunmin/serveo-server" target="_blank">
<img class="img-shield" src="https://img.shields.io/docker/stars/taichunmin/serveo-server.svg?logo=docker">
</a>
</td>
</tr>
</table>
<style>
.reveal {
font-family: '微軟正黑體';
}
.reveal section img.img-shield {
margin: -.2em 0 -.35em 0;
border: 0;
max-height: none;
max-width: none;
height: 50px;
box-shadow: none;
line-height: 1;
}
table.table-shield {
white-space: nowrap;
}
table.table-shield th {
text-align: right;
font-size: 70%;
}
.reveal table.table-shield th, .reveal table.table-shield td {
border: 0;
}
.reveal table.about-me td{
vertical-align: middle;
}
img.avatar {
border-radius: 50%;
width: 300px;
}
.reveal pre code {
max-height: 520px;
}
</style>
{"metaMigratedAt":"2023-06-15T00:56:48.843Z","metaMigratedFrom":"YAML","title":"(含實作) SERVEO 讓你用 Docker 開發 chatbot 也能過的去","breaks":true,"description":"SERVEO 讓你用 Docker 開發 chatbot 也能過的去","slideOptions":"{\"allottedMinutes\":60}","contributors":"[{\"id\":\"0d9a5e06-1f92-4142-b9df-fed4c8873573\",\"add\":9452,\"del\":2550}]"}