Jerry's WIKIJerry's WIKI
概述
  • 🐞 web使用
  • 📐 常用组件
  • 💡 使用技巧
  • 🎱 规范相关
  • 🖥 工作流
  • 🛠 常用工具
  • 🌐️ 服务器
  • 📦 容器相关
  • ♨️ 编程语言
咖啡屋
  • 简体中文
  • English
GitHub
概述
  • 🐞 web使用
  • 📐 常用组件
  • 💡 使用技巧
  • 🎱 规范相关
  • 🖥 工作流
  • 🛠 常用工具
  • 🌐️ 服务器
  • 📦 容器相关
  • ♨️ 编程语言
咖啡屋
  • 简体中文
  • English
GitHub
  • 🐳 Docker

    • Basic
    • CI/CD
    • Volume
    • Network
    • 常用命令
  • 🎛 Docker compose
  • 🕸 Docker swarm
  • 🐙 K8s

CI/CD

目录

  • 构建工作流文件
  • 阿里云镜像管理触发器

主要流程

  1. 本地编码。
  2. 推送代码。(push remote repository)
  3. 构建镜像。(github build image)
  4. 推送镜像。(github push image to target image repository)
  5. 服务器拉取镜像。
  6. 容器重启。

构建工作流文件

# 目录结构
.github
	|- workflows
		|- main.yml
app
Dockerfile

main.yml

name: Build and Publish Docker
on: [push]
jobs: 
  build:
	runs-on: ubuntu-latest
  	name: Build image job
	steps:
  	  - name: Checkout master
      uses: actions/checkout@master
      - name: Build and publish image
      # 这里的工具是Actions广场查找使用的,如果你想更换,在广场搜索即可
      # https://github.com/marketplace/actions
      uses: ilteoood/docker_buildx@master
      with:
    	repository: namespace-image/image-name # 命名空间/镜像名称
        registry: registry.cn-shenzhen.aliyuncs.com # 仓库地址
        username: "xxx" # 仓库用户
        password: "xxx" # 仓库密码
        auto_tag: true
        
# 这里推荐几个好用的Action构建镜像的Action工具
# https://github.com/marketplace/actions/customizable-docker-buildx
# https://github.com/marketplace/actions/push-to-registry
# https://github.com/marketplace/actions/publish-docker-action

阿里云镜像管理触发器

使用阿里云触发器管理镜像更新Action

【注意】

1、可以实现一个 web server 接收阿里云的 webhook 然后主动拉取更新镜像。
2、watchTower 容器也可以实现监听所有容器的镜像是否为最新版,是则拉取更新。

编辑此页面
更新时间:
贡献者: 田朝帆
Prev
Docker
Next
卷的使用