在構建 GitLab CI 流程時,我遇到了一個問題。 我在開發機上建立了 PHP 的 Docker Image,但在 Gitlab-CI Runner 運行 Image 時, 出現了 “standard_init_linux.go:219: exec user process caused: exec format error” 的錯誤。 這個錯誤表示容器內部執行的可執行文件格式不正確或無效。
進一步分析後,我意識到問題可能是由於容器映像與主機操作系統的處理器架構不兼容引起的。 由於我的筆電是基於 Apple M2 晶片的 Mac,它使用的是 ARM 架構,而我的 CI 使用的容器映像可能是針對 x86 架構設計的。
解決方法
Docker for Mac 提供了一個功能稱為「多架構建置(Buildx)」,它允許我們在具有不同處理器架構的環境中建立 Docker Image。 以下是在 Mac 上建立 x86 架構的 Docker Image 的步驟: 確保您已安裝 Docker for Mac,並確保 Docker 客戶端已啟用 Buildx 功能。 可以使用以下命令來檢查是否啟用了 Buildx:
The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code; unlike config files, there is little chance of them being checked into the code repo accidentally; and unlike custom config files, or other config mechanisms such as Java System Properties, they are a language- and OS-agnostic standard.
另一個是 Php Laravel 的官方作法
Laravel utilizes the DotEnv PHP library. In a fresh Laravel installation, the root directory of your application will contain a .env.example file that defines many common environment variables. During the Laravel installation process, this file will automatically be copied to .env.
# 請注意,字符串不需要引號。但是,它們可以使用引號。 however:'A string, enclosed in quotes.' 'Keys can be quoted too.':"Useful if you want to put a ':' in your key." single quotes:'have ''one'' escape pattern' double quotes:"have many: \", \0, \t, \u263A, \x0d\x0a == \r\n, and more." # UTF-8/16/32字符需要編碼 Superscript two:\u00B2
# 特殊字符必須用單引號或雙引號括起來 special_characters:"[ John ] & { Jane } - <Doe>"
# 多行字符串可以使用“文字塊”(使用|)或“折疊塊”(使用'>')來寫入。 # 文字塊會將字符串中的每個換行符轉換為文字換行符(\n)。 # 折疊塊則刪除字符串中的換行符。 literal_block:| This entire block of text will be the value of the 'literal_block' key, with line breaks being preserved. Theliteralcontinuesuntilde-dented,andtheleadingindentationis stripped.
Anylinesthatare'more-indented'keeptherestoftheirindentation- theselineswillbeindentedby4spaces. folded_style:> This entire block of text will be the value of 'folded_style', but this time, all newlines will be replaced with a single space. Blanklines,likeabove,areconvertedtoanewlinecharacter.
# |- 和 >- 可以刪除結尾的空行(也被稱為文字塊的 "strip") literal_strip:|- This entire block of text will be the value of the 'literal_block' key, with trailing blank line being stripped. block_strip:>- This entire block of text will be the value of 'folded_style', but this time, all newlines will be replaced with a single space and trailing blank line being stripped. # |+ 和 >+ 可以保留結尾的空行(也被稱為文字塊的 "keep") literal_keep:|+ This entire block of text will be the value of the 'literal_block' key, with trailing blank line being kept. block_keep:>+ This entire block of text will be the value of 'folded_style', but this time, all newlines will be replaced with a single space and trailing blank line being kept. #################### # 集合類型 # ####################
The new registration process is expected to become available in %16.0, and the legacy registration process will be available side-by-side for a few milestones before the being sunset through a feature flag. Removal is planned for %17.0.