Skip to content

Commit 6577567

Browse files
authored
Merge pull request #683 from ModelEngine-Group/jpl/jpl_0730
🔨 add community deployment script with terminal container support.
2 parents b691b27 + 513e86d commit 6577567

File tree

4 files changed

+587
-59
lines changed

4 files changed

+587
-59
lines changed
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
name: Docker Build and Push All Images to tencentyun
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
runner_label_json:
7+
description: 'JSON 格式的 runner 标签数组(如 ["ubuntu-latest"] 或 ["self-hosted"])'
8+
required: true
9+
default: '["ubuntu-latest"]'
10+
11+
jobs:
12+
build-and-push-main-amd64:
13+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
14+
steps:
15+
- name: Set up Docker Buildx
16+
run: |
17+
if ! docker buildx inspect nexent_builder > /dev/null 2>&1; then
18+
docker buildx create --name nexent_builder --use
19+
else
20+
docker buildx use nexent_builder
21+
fi
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
- name: Build main image (amd64) and load locally
25+
run: |
26+
docker buildx build --platform linux/amd64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent:amd64 -f make/main/Dockerfile .
27+
- name: Login to Tencent Cloud
28+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
29+
- name: Push main image (amd64) to Tencent Cloud
30+
run: docker push ccr.ccs.tencentyun.com/nexent-hub/nexent:amd64
31+
32+
build-and-push-main-arm64:
33+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
34+
steps:
35+
- name: Set up Docker Buildx
36+
run: |
37+
if ! docker buildx inspect nexent_builder > /dev/null 2>&1; then
38+
docker buildx create --name nexent_builder --use
39+
else
40+
docker buildx use nexent_builder
41+
fi
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
- name: Build main image (arm64) and load locally
45+
run: |
46+
docker buildx build --platform linux/arm64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent:arm64 -f make/main/Dockerfile .
47+
- name: Login to Tencent Cloud
48+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
49+
- name: Push main image (arm64) to Tencent Cloud
50+
run: docker push ccr.ccs.tencentyun.com/nexent-hub/nexent:arm64
51+
52+
build-and-push-data-process-amd64:
53+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
54+
steps:
55+
- name: Free up disk space on GitHub runner
56+
run: |
57+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
58+
- name: Set up Docker Buildx
59+
run: |
60+
if ! docker buildx inspect nexent_builder > /dev/null 2>&1; then
61+
docker buildx create --name nexent_builder --use
62+
else
63+
docker buildx use nexent_builder
64+
fi
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
- name: Clone model
68+
run: |
69+
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/Nexent-AI/model-assets
70+
cd ./model-assets
71+
GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_LFS_LOG=debug git lfs pull
72+
rm -rf .git .gitattributes
73+
- name: Build data process image (amd64) and load locally
74+
run: |
75+
docker buildx build --platform linux/amd64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:amd64 -f make/data_process/Dockerfile .
76+
- name: Login to Tencent Cloud
77+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
78+
- name: Push data process image (amd64) to Tencent Cloud
79+
run: docker push ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:amd64
80+
81+
build-and-push-data-process-arm64:
82+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
83+
steps:
84+
- name: Free up disk space on GitHub runner
85+
run: |
86+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
87+
- name: Set up Docker Buildx
88+
run: |
89+
if ! docker buildx inspect nexent_builder > /dev/null 2>&1; then
90+
docker buildx create --name nexent_builder --use
91+
else
92+
docker buildx use nexent_builder
93+
fi
94+
- name: Checkout code
95+
uses: actions/checkout@v4
96+
- name: Clone model
97+
run: |
98+
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/Nexent-AI/model-assets
99+
cd ./model-assets
100+
GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_LFS_LOG=debug git lfs pull
101+
rm -rf .git .gitattributes
102+
- name: Build data process image (arm64) and load locally
103+
run: |
104+
docker buildx build --platform linux/arm64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:arm64 -f make/data_process/Dockerfile .
105+
- name: Login to Tencent Cloud
106+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
107+
- name: Push data process image (arm64) to Tencent Cloud
108+
run: docker push ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:arm64
109+
110+
build-and-push-web-amd64:
111+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
112+
steps:
113+
- name: Set up Docker Buildx
114+
run: |
115+
if ! docker buildx inspect nexent_builder > /dev/null 2>&1; then
116+
docker buildx create --name nexent_builder --use
117+
else
118+
docker buildx use nexent_builder
119+
fi
120+
- name: Checkout code
121+
uses: actions/checkout@v4
122+
- name: Build web image (amd64) and load locally
123+
run: |
124+
docker buildx build --platform linux/amd64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent-web:amd64 -f make/web/Dockerfile .
125+
- name: Login to Tencent Cloud
126+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
127+
- name: Push web image (amd64) to Tencent Cloud
128+
run: docker push ccr.ccs.tencentyun.com/nexent-hub/nexent-web:amd64
129+
130+
build-and-push-web-arm64:
131+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
132+
steps:
133+
- name: Set up Docker Buildx
134+
run: |
135+
if ! docker buildx inspect nexent_builder > /dev/null 2>&1; then
136+
docker buildx create --name nexent_builder --use
137+
else
138+
docker buildx use nexent_builder
139+
fi
140+
- name: Checkout code
141+
uses: actions/checkout@v4
142+
- name: Build web image (arm64) and load locally
143+
run: |
144+
docker buildx build --platform linux/arm64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent-web:arm64 -f make/web/Dockerfile .
145+
- name: Login to Tencent Cloud
146+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
147+
- name: Push web image (arm64) to Tencent Cloud
148+
run: docker push ccr.ccs.tencentyun.com/nexent-hub/nexent-web:arm64
149+
150+
manifest-push-main:
151+
runs-on: ubuntu-latest
152+
needs:
153+
- build-and-push-main-amd64
154+
- build-and-push-main-arm64
155+
steps:
156+
- name: Login to Tencent Cloud
157+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
158+
- name: Create and push manifest for main (Tencent Cloud)
159+
run: |
160+
docker manifest create ccr.ccs.tencentyun.com/nexent-hub/nexent:latest \
161+
ccr.ccs.tencentyun.com/nexent-hub/nexent:amd64 \
162+
ccr.ccs.tencentyun.com/nexent-hub/nexent:arm64
163+
docker manifest push ccr.ccs.tencentyun.com/nexent-hub/nexent:latest
164+
165+
manifest-push-data-process:
166+
runs-on: ubuntu-latest
167+
needs:
168+
- build-and-push-data-process-amd64
169+
- build-and-push-data-process-arm64
170+
steps:
171+
- name: Login to Tencent Cloud
172+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
173+
- name: Create and push manifest for data-process (Tencent Cloud)
174+
run: |
175+
docker manifest create ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:latest \
176+
ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:amd64 \
177+
ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:arm64
178+
docker manifest push ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:latest
179+
180+
manifest-push-web:
181+
runs-on: ubuntu-latest
182+
needs:
183+
- build-and-push-web-amd64
184+
- build-and-push-web-arm64
185+
steps:
186+
- name: Login to Tencent Cloud
187+
run: echo ${{ secrets.TCR_PASSWORD }} | docker login ccr.ccs.tencentyun.com --username=${{ secrets.TCR_USERNAME }} --password-stdin
188+
- name: Create and push manifest for web (Tencent Cloud)
189+
run: |
190+
docker manifest create ccr.ccs.tencentyun.com/nexent-hub/nexent-web:latest \
191+
ccr.ccs.tencentyun.com/nexent-hub/nexent-web:amd64 \
192+
ccr.ccs.tencentyun.com/nexent-hub/nexent-web:arm64
193+
docker manifest push ccr.ccs.tencentyun.com/nexent-hub/nexent-web:latest

.github/workflows/docker-build-push.yml renamed to .github/workflows/docker-build-push-overseas.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Build and Push All Images
1+
name: Docker Build and Push All Images to DockerHub
22

33
on:
44
workflow_dispatch:
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v4
2424
- name: Build main image (amd64) and load locally
2525
run: |
26-
docker buildx build --platform linux/amd64 -t nexent/nexent:amd64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent:amd64 -f make/main/Dockerfile .
26+
docker buildx build --platform linux/amd64 -t nexent/nexent:amd64 --load -f make/main/Dockerfile .
2727
- name: Login to DockerHub
2828
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u nexent --password-stdin
2929
- name: Push main image (amd64) to DockerHub
@@ -43,7 +43,7 @@ jobs:
4343
uses: actions/checkout@v4
4444
- name: Build main image (arm64) and load locally
4545
run: |
46-
docker buildx build --platform linux/arm64 -t nexent/nexent:arm64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent:arm64 -f make/main/Dockerfile .
46+
docker buildx build --platform linux/arm64 -t nexent/nexent:arm64 --load -f make/main/Dockerfile .
4747
- name: Login to DockerHub
4848
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u nexent --password-stdin
4949
- name: Push main image (arm64) to DockerHub
@@ -72,7 +72,7 @@ jobs:
7272
rm -rf .git .gitattributes
7373
- name: Build data process image (amd64) and load locally
7474
run: |
75-
docker buildx build --platform linux/amd64 -t nexent/nexent-data-process:amd64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:amd64 -f make/data_process/Dockerfile .
75+
docker buildx build --platform linux/amd64 -t nexent/nexent-data-process:amd64 --load -f make/data_process/Dockerfile .
7676
- name: Login to DockerHub
7777
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u nexent --password-stdin
7878
- name: Push data process image (amd64) to DockerHub
@@ -101,7 +101,7 @@ jobs:
101101
rm -rf .git .gitattributes
102102
- name: Build data process image (arm64) and load locally
103103
run: |
104-
docker buildx build --platform linux/arm64 -t nexent/nexent-data-process:arm64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent-data-process:arm64 -f make/data_process/Dockerfile .
104+
docker buildx build --platform linux/arm64 -t nexent/nexent-data-process:arm64 --load -f make/data_process/Dockerfile .
105105
- name: Login to DockerHub
106106
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u nexent --password-stdin
107107
- name: Push data process image (arm64) to DockerHub
@@ -121,7 +121,7 @@ jobs:
121121
uses: actions/checkout@v4
122122
- name: Build web image (amd64) and load locally
123123
run: |
124-
docker buildx build --platform linux/amd64 -t nexent/nexent-web:amd64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent-web:amd64 -f make/web/Dockerfile .
124+
docker buildx build --platform linux/amd64 -t nexent/nexent-web:amd64 --load -f make/web/Dockerfile .
125125
- name: Login to DockerHub
126126
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u nexent --password-stdin
127127
- name: Push web image (amd64) to DockerHub
@@ -141,7 +141,7 @@ jobs:
141141
uses: actions/checkout@v4
142142
- name: Build web image (arm64) and load locally
143143
run: |
144-
docker buildx build --platform linux/arm64 -t nexent/nexent-web:arm64 --load -t ccr.ccs.tencentyun.com/nexent-hub/nexent-web:arm64 -f make/web/Dockerfile .
144+
docker buildx build --platform linux/arm64 -t nexent/nexent-web:arm64 --load -f make/web/Dockerfile .
145145
- name: Login to DockerHub
146146
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u nexent --password-stdin
147147
- name: Push web image (arm64) to DockerHub
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Deploy Nexent Community
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
deployment_mode:
7+
description: '部署模式: development or production'
8+
required: true
9+
default: 'development'
10+
type: choice
11+
options:
12+
- development
13+
- production
14+
runner_label_json:
15+
description: 'JSON 格式的 runner 标签数组'
16+
required: true
17+
default: '[]'
18+
19+
jobs:
20+
build-main:
21+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 1
27+
retries: 3
28+
- name: Build main application image
29+
run: docker build --build-arg MIRROR=https://pypi.tuna.tsinghua.edu.cn/simple -t nexent/nexent -f make/main/Dockerfile .
30+
31+
build-data-process:
32+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 1
38+
retries: 3
39+
- name: Check if model is cached locally
40+
id: check-model
41+
run: |
42+
if [ -f ~/model-assets/clip-vit-base-patch32/config.json ] && [ -d ~/model-assets/nltk_data ]; then
43+
echo "cache-hit=true" >> "$GITHUB_OUTPUT"
44+
cp -r ~/model-assets ./
45+
else
46+
echo "cache-hit=false" >> "$GITHUB_OUTPUT"
47+
fi
48+
- name: Clone model if not cached
49+
if: steps.check-model.outputs.cache-hit == 'false'
50+
run: |
51+
GIT_LFS_SKIP_SMUDGE=1 git clone https://hf-mirror.com/Nexent-AI/model-assets
52+
cd ./model-assets
53+
GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_LFS_LOG=debug git lfs pull
54+
rm -rf .git .gitattributes
55+
- name: Build data process image
56+
run: docker build --build-arg MIRROR=https://pypi.tuna.tsinghua.edu.cn/simple -t nexent/nexent-data-process -f make/data_process/Dockerfile .
57+
58+
build-web:
59+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 1
65+
retries: 3
66+
- name: Build web frontend image
67+
run: docker build --build-arg MIRROR=https://registry.npmmirror.com -t nexent/nexent-web -f make/web/Dockerfile .
68+
69+
deploy:
70+
runs-on: ${{ fromJson(inputs.runner_label_json) }}
71+
needs: [ build-main, build-data-process, build-web ]
72+
steps:
73+
- name: Checkout code
74+
uses: actions/checkout@v4
75+
with:
76+
fetch-depth: 1
77+
retries: 3
78+
- name: Copy project to $HOME/nexent
79+
run: |
80+
rm -rf $HOME/nexent
81+
mkdir -p $HOME/nexent
82+
cp -r $GITHUB_WORKSPACE/* $HOME/nexent/
83+
- name: Ensure deploy.sh is executable
84+
run: chmod +x $HOME/nexent/docker/deploy.sh
85+
- name: Deploy with deploy.sh
86+
env:
87+
DEPLOYMENT_MODE: ${{ github.event.inputs.deployment_mode }}
88+
run: |
89+
cd $HOME/nexent/docker
90+
cp .env.example .env
91+
if [ "$DEPLOYMENT_MODE" = "production" ]; then
92+
./deploy.sh --mode 3 --is-mainland N --enable-terminal N
93+
else
94+
./deploy.sh --mode 1 --is-mainland N --enable-terminal N
95+
fi

0 commit comments

Comments
 (0)