2020年7月21日 星期二

docker 相關指令

docker 相關指令


映像檔相關指令

  • 建立映像檔
       docker build -t {映像檔名} .  :記得在dockerfile所在的目錄輸入





容器相關指令


  • 運行容器

       docker run

       run 以 Image 來建立 Container
       示例:
       docker run -it --name {想要取的名稱} -p 5555:80 {images}


       相關參數:
       -p  {本機port}:{容器port}  : 指定把容器的 port 綁到本機的 port

       -d  :  背景執行

       -i  :  讓 Container 的標準輸入保持打開

       -t  :  讓Docker分配一個虛擬終端(pseudo-tty)並綁定到 Container 的標準輸入上

       -v  : 可以指定本地資料夾映射到容器內的哪個資料夾

       --name 可以幫自己容器取名字
--------------------------------------------------------------------------------------
       run 與 start 差異

       ctrl+p + ctrl+q 可以跳出bash而不停止容器

  • 移除容器
       docker rm {容器id}
       相關指令
       -f : 強制停止,不然rm前都需要先stop容器
  • 查看容器
       docker ps
       相關指令
       -a : 查看執行過的容器
       --format : 排版  ex: docker ps --format table"{{.欄位}}/t{{.欄位}}/t"


將檔案推上Docker Hub

1. 為image加上tag,加完用docker images就會看到
    docker tag ${image Name} DockerHub 帳號/image Name

2.推上去DockerHub 
    docker login=> docker push DockerHub 帳號/image Name

3. 拉下來
    docker pull 

將image 匯出成壓縮檔(tar)

    docker save -o 自己取檔名.tar ${image name}

    docker export ${image name} > 自己取的檔名.tar

     

    ***********************
    save 、 export差異   export會將容器內所改變的東西全部打包匯出,
    可 save 單純只儲存 Image ,所以為了持續使用 Container 要使用 export 這個指令
    ***********************
    相關參數 :
      -o : 輸出檔案

將image匯入

   docker import - 自己取個鏡像名 < tar檔

    cat tar檔 | docker import - 自己取個鏡像名

Docker Volume功能:可把資料寫在實體機器上
    
    1. docker run -it -v 實體檔案位置:容器內檔案位置 {image name}
      2. 自己建立一個volume:
              docker volume create  自己取名字,然後再用-v 映射到container 檔案

共享兩個Container檔案(-v跟--volume一樣)
     
     1. 先開啟一個container

            docker run -it -v 實體檔案:容器內檔案位置 --name=容器1 image name

      2. 開啟第二個container 使用--volume-from 容器1

            docker run -it -v-from 容器1 --name=容器2 image name

查看容器訊息

    docker inspect









2020年7月14日 星期二

telegram bot

1. First Bot 的 token

1071865921:AAF-yxkGqL3ICDkUsXGhrMXA3r9KjW8be28

2. channel ID

-1001218272236





3. telegram bot 資訊(First Bot)


{"ok":true,"result":{"id":1071865921,"is_bot":true,"first_name":"First Bot","username":"austin72905_bot","can_join_groups":true,"can_read_all_group_messages":false,"supports_inline_queries":false}}

4. 設一個webhook才能接收訊息(用getUpdate得到的資訊)


{"ok":true,"result":[{"update_id":76191705,
"message":{"message_id":83,"from":{"id":1143269186,"is_bot":false,"first_name":"Austin","last_name":"Lin","username":"austin72905TW","language_code":"zh-hans"},"chat":{"id":1143269186,"first_name":"Austin","last_name":"Lin","username":"austin72905TW","type":"private"},"date":1584461581,"text":"\u5b89\u5b89"}}]}


5. bot 傳送訊息

https://api.telegram.org/bot1071865921:AAF-yxkGqL3ICDkUsXGhrMXA3r9KjW8be28/sendMessage?chat_id=1143269186&text=%E4%BD%A0%E5%A5%BD

6. bot 傳送訊息的JSON

{"ok":true,"result":{"message_id":92,"from":{"id":1071865921,"is_bot":true,"first_name":"First Bot","username":"austin72905_bot"},"chat":{"id":1143269186,"first_name":"Austin","last_name":"Lin","username":"austin72905TW","type":"private"},"date":1584505179,"text":"\u4f60\u597d"}}


7. 設定webhook 響應方式

(1)通用URL
(2)First bot 設定

(3)在家用的
https://api.telegram.org/bot1071865921:AAF-yxkGqL3ICDkUsXGhrMXA3r9KjW8be28/setwebhook?url=https://8a287be6.ngrok.io


------------- norok 部分 ------------------

ngrok 網址

https://blog.alantsai.net/posts/2018/04/devtooltips-5-ngrok-allow-public-to-access-localhost-website-and-sql-server

8. ngrok token:

1ZHbSkF627Mpm53irDWZRBiyXRf_7fMVtb2turMtV1mafZaaB

9. ngrok 隨機產生的網址

ngrok http -host-header=rewrite https://localhost:23283/
家裡的:
ngrok http -host-header=rewrite https://localhost:44351/






---------telegram bot 相關網址--------------------


c# telegram bot library


webhook 概念


http://studyhost.blogspot.com/2016/06/telegram-bot.html

C# 透過 Telegram Bot 發送訊息

一步步打造 Telegram Bot

telegram bot 文擋

Python Telegram Bot 教學 (by 陳達仁)

淺談開發機器人php





-------interface(介面)的用處--------------


為何設計service 曾要先寫介面?
將實現與使用分離開來,只要專注在實現就好
Controller一定要儘量少的邏輯,其實反過來說,是指Service的邏輯應該高內聚,這樣Controller如Service的耦合自然就是最低,Controller真真正正的坐到,不用理會Service的實現,只需要呼叫即可。

iservice   service 分開
controller 跟 service 分開
第三方機器人的service不寫在第三方專案就要寫在第四方?
(第三方機器人不能直接呼叫第三方專案)
過多的商業邏輯處理反而會讓 Controller 的流程控制與商業邏輯混在一起





vue的筆記

 目錄 //mvvm //綁定 //資料綁定的方式 //修飾符 //按鍵修飾符 //縮寫 //class 動態切換 //computed //表單裡各元素的v-model綁定 //元件: 能夠獨立儲存自己的狀態 //vue 的生命週期 //切換className的各種寫法 //v...