forked from chatchat-space/Langchain-Chatchat
-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (160 loc) · 6.34 KB
/
docker-build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: docker-build
on:
push:
branches:
- master
- feat/docker-action
paths-ignore:
- 'README.md'
- 'README_en.md'
- 'docs/**'
# - '.github/**'
- 'docker/docker-compose.yaml'
pull_request:
branches:
- master
types:
- closed
paths-ignore:
- 'README.md'
- 'README_en.md'
- 'docs/**'
- '.github/**'
- 'docker/docker-compose.yaml'
env:
TZ: Asia/Shanghai
RELEASE_VERSION: 0.3.1
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
# - name: Optimize Disk Space
# uses: hugoalh/[email protected]
# with:
# operate_sudo: "True"
# general_include: ".+"
# general_exclude: |-
# ^GCC$
# ^G\+\+$
# Clang
# LLVM
# docker_include: ".+"
# docker_prune: "True"
# docker_clean: "True"
# apt_prune: "True"
# apt_clean: "True"
# homebrew_prune: "True"
# homebrew_clean: "True"
# npm_prune: "True"
# npm_clean: "True"
# os_swap: "True"
# - name: Remove Unnecessary Tools And Files
# env:
# DEBIAN_FRONTEND: noninteractive
# run: |
# sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'php.*' azure-cli google-chrome-stable firefox powershell mono-devel
# sudo apt-get autoremove --purge -y
# sudo find /var/log -name "*.gz" -type f -delete
# sudo rm -rf /var/cache/apt/archives
# sudo rm -rf /tmp/*
# sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /etc/mysql /etc/php
# sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* hhvm* llvm* firefox* google* dotnet* aspnetcore* powershell* openjdk* adoptopenjdk* mysql* php* mongodb* moby* snap* || true
# sudo rm -rf /etc/apt/sources.list.d/* /usr/local/lib/android /opt/ghc /usr/share/dotnet /usr/local/graalvm /usr/local/.ghcup \
# /usr/local/share/powershell /usr/local/share/chromium /usr/local/lib/node_modules
# sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /etc/mysql /etc/php
# sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* hhvm* llvm* firefox* google* dotnet* aspnetcore* powershell* openjdk* adoptopenjdk* mysql* php* mongodb* moby* snap* || true
# sudo -E apt-get -qq update
# sudo -E apt-get -qq install libfuse-dev $(curl -fsSL git.io/depends-ubuntu-2204)
# sudo -E apt-get -qq autoremove --purge
# sudo -E apt-get -qq clean
# sudo apt-get clean
# rm -rf /opt/hostedtoolcache
# sudo timedatectl set-timezone "$TZ"
# - name: Free Up Disk Space
# uses: easimon/maximize-build-space@master
# with:
# root-reserve-mb: 20480 # 给 / 预留 20GiB 空间( docker 预留)
# swap-size-mb: 1
# remove-dotnet: 'true'
# remove-android: 'true'
# remove-haskell: 'true'
# remove-codeql: 'true'
# remove-docker-images: 'true'
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set DockerImage Tag
id: imageTag
run: echo "image_tag=${RELEASE_VERSION}-$(git rev-parse --short HEAD)-$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Set Up QEMU
uses: docker/setup-qemu-action@v2
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login To Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
- name: Login To Tencent CCR
uses: docker/login-action@v2
with:
registry: ccr.ccs.tencentyun.com
username: ${{ secrets.CCR_REGISTRY_USERNAME }}
password: ${{ secrets.CCR_REGISTRY_PASSWORD }}
- name: Show Runner Disk
run: df -hT
# - name: Build and push Docker image
# uses: docker/build-push-action@v4
# with:
# context: ./docker
# file: ./docker/Dockerfile
# push: true
# tags: |
# chatimage/chatchat:${{ env.image_tag }}
# ccr.ccs.tencentyun.com/langchain-chatchat/chatchat:${{ env.image_tag }}
# platforms: |
# linux/amd64, linux/arm64
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ./docker
file: ./docker/Dockerfile
push: true
tags: |
chatimage/chatchat:${{ env.image_tag }}
platforms: |
linux/amd64
- name: Logout from Docker Hub
run: docker logout
- name: Logout from Tencent Cloud Container Registry
run: docker logout ccr.ccs.tencentyun.com
- name: Update README and docker-compose.yaml
run: |
# 更新文件内容
sed -i -E "s|chatimage/chatchat:[a-zA-Z0-9._-]+|chatimage/chatchat:${{ env.image_tag }}|g" README.md README_en.md docker/docker-compose.yaml
sed -i -E "s|ccr.ccs.tencentyun.com/langchain-chatchat/chatchat:[a-zA-Z0-9._-]+|ccr.ccs.tencentyun.com/langchain-chatchat/chatchat:${{ env.image_tag }}|g" README.md README_en.md docker/docker-compose.yaml
# 配置 Git 用户信息
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# 创建新的分支
git checkout -b update-docker-image-${{ env.image_tag }}
# 检查是否有更改
if git diff --quiet; then
echo "No changes to commit"
exit 0
fi
# 提交更改
git commit -am "feat: update docker image to ${{ env.image_tag }}"
# 推送到新的分支
git push origin update-docker-image-${{ env.image_tag }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "feat: update docker image to ${{ env.image_tag }}"
branch: update-docker-image-${{ env.image_tag }}
base: master # 确保 base 是目标分支
title: "Update Docker image to ${{ env.image_tag }}"
body: "This PR updates the Docker image to ${{ env.image_tag }}."
labels: |
docker
automated-pr