# **Q1 :** # basic `config.yaml` : ``` application: name: "MyWebApp" version: "1.0.2" debug_mode: true servers: - id: "web_01" host: "192.168.1.10" port: 8080 tags: ["production", "frontend"] - id: "db_01" host: "10.0.0.5" port: 5432 tags: ["production", "backend", "database"] settings: timeout_seconds: 30 log_level: "info" ``` 1.假設 YAML 內容如上,要如何使用 yq 指令取出應用程式的名稱(MyWebApp)? Ans : `yq '.application' config.yaml` 2.要取出 servers 陣列中第一個伺服器的主機埠號(8080),應該使用哪個 yq 指令? Ans : `yq .servers[0].port' config.yaml` 3.請使用 yq 指令取出 `config.yaml` 中 所有伺服器 的 host 值,並將其列印出來。 Ans : `yq .'severs[].host 'config.yaml` # advanced 4.若要將 log_level 的值從 info 修改為 debug,但不改變檔案中的其他內容,應使用哪個 yq 指令? Ans : `yq '.settings.log_level = "debug"' config.yaml` 5.如果要查詢 id 為 db_01 的伺服器主機(host),應該使用哪個 yq 指令來進行過濾? Ans : `yq 'servers[] | select(.id == "db_01") config.yaml` 6.要完全移除 application 區塊中的 debug_mode: true 這一行,應該使用哪個 yq 指令? Ans : `yq 'del(.application.debug_mode)' config.yaml` # Q2 : 部署 Python Flask 反向代理 🎯 專案情境 您現在接手一個 Python Flask 專案。開發人員已經編寫好了應用程式碼 (`app.py`) 和 Nginx 設定檔 (`nginx.conf`)。您的任務是負責將這整套服務使用 Docker Compose 部署上線。 資料夾格式 :  `app.py` :  任務 A: app/Dockerfile  任務 B: docker-compose.yml 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up