owned this note changed 4 years ago
Linked with GitHub

Rails 容器化最佳實踐 - Cindy

tags: COSCUP2021 zh-tw COSCUP2021 RubyConf Taiwan 2021 TR214 - Ruby Conf

歡迎來到 https://hackmd.io/@coscup/2021 共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

點擊本頁上方的 開始用 Markdown 一起寫筆記!
手機版請點選上方 按鈕展開議程列表。

請從這裡開始

Slide: https://hackmd.io/@cindyliu923/SkDyRZeYd#/

Q & A

  1. 怎麼知道要裝哪些套件?
    基本知道的就會先裝,其他不確定的看錯誤訊息再補上。
    比較難的方式:在 Mac (otool)與 Linux (ldd)可以使用指令找動態依賴套件。
    在 local 的話可以用 docker-compose 跑起來看看訊息。
    比較好的方式:一定要有類似 production 的測試環境。

  2. asset precompile 時需要 env var 的 value,請問在 CI 上可以如何處理?
    不清楚問題的實際場景,先跳過了。

    Cindy 補充:

    • 如果是指 gitlab ci 在做 asset precompile 會需要 RAILS_ENV production 的話,會將以下設定在 job 中:
    ​​​​  variables:
    ​​​​    RAILS_ENV: production
    
    • 如果是指 gitlab ci 的環境變數怎麼設定的話,可以在如下畫面中設定:
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
  3. 想問一下,為什麼要新增 rails user?
    Docker 通常預設的 user 是 root,為了安全性考量,會建議額外建立執行指令的 user。
    Top 20 Dockerfile best practices - Rootless containers
    Best practices for writing Dockerfiles

  4. 如何在 apline linx 環境中安裝並使用 mysql 8.0 函式庫?除了改用 postgresql 與 mariadb 以外
    不確定,希望有經驗的人可以分享

Select a repo