返回文章列表

CI 工具鏈 with Docker (4) — Bootstrap Jenkins 靜態網站 nginx

2017-06-21
1 分鐘
JenkinsNginxCI

系列文章:

Overview

本篇說明如何用 Jenkins、Docker、Nginx 建立靜態網頁專案的 CI/CD pipeline。

Setup Steps

  1. 初始化專案
  2. Push 到 GitLab repository,取得 repository URI
  3. 建立 Jenkins 專用的 GitLab 使用者,設定 SSH 金鑰(public key)
  4. 在 Docker 上跑 Nginx 容器,掛載靜態內容與 nginx 設定檔兩個 volume:
    sudo docker run --name um1215-client \
      -v /home/administrator/um1215/:/usr/share/nginx/html:ro \
      -v /home/administrator/um1215/nginx.conf:/etc/nginx/nginx.conf:ro \
      -p 21201:80 -d --restart=unless-stopped nginx
    參考:nginx.conf 設定範例
  5. 設定 Jenkins task:
    • 取得 webhook 連結並加入 GitLab
    • 設定 private key 與 repository URI 以供 Jenkins 取得專案
    • 若使用 Node.js,選擇 nvm wrapper 並指定版本
    • 新增 shell 建置指令:
      npm install
      npm install -d
      npm run build
  6. 設定 Publish Over SSH
  7. 完成設定

原文發表於 Medium

Command Palette

Search for a command to run...