CI/CD
็ฎๅฝ
Main Process
- Local coding.
- Push code. (push remote repository)
- Build image. (github build image)
- Push image. (github push image to target image repository)
- Server pulls image.
- Container restart.
Build Workflow File
# Directory structure
.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
# Here are some recommended Action tools for building images:
# https://github.com/marketplace/actions/customizable-docker-buildx
# https://github.com/marketplace/actions/push-to-registry
# https://github.com/marketplace/actions/publish-docker-action
Alibaba Cloud Image Management Trigger
Use Alibaba Cloud trigger to manage image update actions.
ใTipใ
- You can implement a
web server
to receive Alibaba Cloud'swebhook
and then actively pull the updated image. - The
watchTower
container can also monitor whether all containers' images are up-to-date, and if so, it will pull updates.