Youtube 頻道:https://www.youtube.com/c/kaochenlong
如果畫面太小或看不清楚
可移駕至 https://www.youtube.com/watch?v=k9XmJTh0vk4 觀看 4K 高畫質版本
如果喜歡這個系列的影片,歡迎訂閱我的頻道
或是想聽我介紹一些別的內容,也可直接在這裡或 YouTube 頁面下方留言 :)
DigitalOcean 推薦連結:https://ubin.io/doo
GitLab 專案:https://gitlab.com/kaochenlong/shopping-cat-v2
檔案:.gitlab-ci.yml
stages:
- testing
- build
- publish
- deploy_to_dev
- deploy_to_staging
deploy-to-dev:
stage: deploy_to_dev
before_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$DEV_SERVER_PRIVATE_KEY")
script:
- scp -o StrictHostKeyChecking=no ./docker-compose.yml $DEV_SERVER_USER@$DEV_SERVER_URL:/root
- ssh -o StrictHostKeyChecking=no $DEV_SERVER_USER@$DEV_SERVER_URL "
export COMPOSE_PROJECT_NAME=dev
export APP_PORT=3000
docker-compose down &&
docker-compose up -d
"
environment:
name: dev
url: http://$DEV_SERVER_URL:3000
deploy-to-staging:
stage: deploy_to_staging
before_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$DEV_SERVER_PRIVATE_KEY")
script:
- scp -o StrictHostKeyChecking=no ./docker-compose.yml $DEV_SERVER_USER@$DEV_SERVER_URL:/root
- ssh -o StrictHostKeyChecking=no $DEV_SERVER_USER@$DEV_SERVER_URL "
export COMPOSE_PROJECT_NAME=staging
export APP_PORT=5000
docker-compose down &&
docker-compose up -d
"
environment:
name: staging
url: http://$DEV_SERVER_URL:5000
檔案:docker-compose.yml
version: "3.9"
services:
cat:
image: registry.gitlab.com/kaochenlong/shopping-cat-v2
ports:
- ${APP_PORT}:8000
restart: always
各集影片連結:
Day 01 - 為你自己學 GitLab CI/CD
Day 02 - 什麼是 CI/CD
Day 03 - 建立 .gitlab-ci.yml
Day 04 - 新增 Pipeline Job
Day 05 - 工作階段以及相依性
Day 06 - 執行外部檔案
Day 07 - 指定分支
Day 08 - 環境變數
Day 09 - GitLab CI 與 Docker Image
Day 10 - Runner 與 Executor
Day 11 - 在本機的 GitLab Runner
Day 12 - 在 DigitalOcean 上安裝 GitLab Runner
Day 13 - Group Runner
Day 14 - 專案演練 part 1 設定 Pipeline
Day 15 - 專案演練 part 2 把專案打包成 Docker Image
Day 16 - 專案演練 part 3 推上 Docker Registry
Day 17 - 專案演練 part 4 自動遞增 Image 版號
Day 18 - 使用 Docker Compose
Day 19 - 使用 SSH 連線伺服器
Day 20 - 部署 Image 到伺服器上
Day 21 - 部署 Staging 伺服器
Day 22 - 整理重複的工作
Day 23 - 手動部署 Production 環境
Day 24 - Artifacts 產物
Day 25 - Deploy on AWS part 1
Day 26 - Deploy on AWS part 2
Day 27 - Deploy on AWS part 3
Day 28 - Deploy on GCP part 1
Day 29 - Deploy on GCP part 2
Day 30 - 重點回顧