Skip to content

Commit dc03d68

Browse files
committed
👷 ci(cnb): 更新 Docker 镜像构建工作流配置。
- 移除旧的手动 Docker 构建步骤。 - 启用 rootlessBuildkitd 选项以支持无根构建。 - 优化 Docker 登录方式,使用 `--password-stdin` 提升安全性。 👷 ci(github): 新增同步到 CNB 仓库的工作流。 - 创建 `sync-to-cnb.yml` 工作流文件。 - 配置自动同步代码到 CNB 仓库。 - 使用 `tencentcom/git-sync` 容器进行同步操作。
1 parent 64ac865 commit dc03d68

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

.cnb/workflows/build-docker-images.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ main:
33
- runner:
44
cpus: 8
55
services:
6-
- docker
76
- git-clone-yyds
7+
- name: docker
8+
options:
9+
rootlessBuildkitd:
10+
enabled: true
811
imports:
912
- https://cnb.cool/eryajf/build-env/-/blob/main/env.yaml
1013
env:
@@ -23,14 +26,6 @@ main:
2326
timeout: 3h
2427
script: |
2528
echo ${ALIHUB_TOKEN} | docker login -u ${ALIHUB_USERNAME} --password-stdin ${ALIHUB_URL}
26-
docker run -d --name buildkitd \
27-
--security-opt seccomp=unconfined \
28-
--security-opt apparmor=unconfined \
29-
--security-opt systempaths=unconfined \
30-
moby/buildkit:rootless
31-
docker buildx create --use \
32-
--name mybuilder \
33-
--driver remote docker-container://buildkitd
3429
docker buildx build \
3530
-t ${ALIHUB_URL}/${ALIHUB_USERNAME}/${IMAGE_NAME} \
3631
-t ${ALIHUB_URL}/${ALIHUB_USERNAME}/${IMAGE_NAME}:${CNB_BRANCH}_`date "+%Y%m%d%H%M%S"` \

.cnb/workflows/release.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ $:
33
- runner:
44
cpus: 8
55
services:
6-
- docker
76
- git-clone-yyds
7+
- name: docker
8+
options:
9+
rootlessBuildkitd:
10+
enabled: true
811
env:
912
IMAGE_NAME: "go-ldap-admin"
1013
DOCKERHUB_USERNAME: eryajf
@@ -29,15 +32,7 @@ $:
2932
- name: 🐋 推送镜像
3033
timeout: 3h
3134
script: |
32-
docker login -u ${ALIHUB_USERNAME} -p ${ALIHUB_TOKEN} ${ALIHUB_URL}
33-
docker run -d --name buildkitd \
34-
--security-opt seccomp=unconfined \
35-
--security-opt apparmor=unconfined \
36-
--security-opt systempaths=unconfined \
37-
moby/buildkit:rootless
38-
docker buildx create --use \
39-
--name mybuilder \
40-
--driver remote docker-container://buildkitd
35+
echo ${ALIHUB_TOKEN} | docker login -u ${ALIHUB_USERNAME} --password-stdin ${ALIHUB_URL}
4136
docker buildx build \
4237
-t ${ALIHUB_URL}/${ALIHUB_USERNAME}/${IMAGE_NAME} \
4338
-t ${ALIHUB_URL}/${ALIHUB_USERNAME}/${IMAGE_NAME}:${CNB_BRANCH} \

.github/workflows/sync-to-cnb.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Sync to CNB
2+
3+
on: [push]
4+
5+
jobs:
6+
sync:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
fetch-depth: 0
12+
13+
- name: Sync to CNB Repository
14+
run: |
15+
docker run --rm \
16+
-v ${{ github.workspace }}:${{ github.workspace }} \
17+
-w ${{ github.workspace }} \
18+
-e PLUGIN_TARGET_URL="https://cnb.cool/opsre/go-ldap-admin.git" \
19+
-e PLUGIN_AUTH_TYPE="https" \
20+
-e PLUGIN_USERNAME="cnb" \
21+
-e PLUGIN_PASSWORD=${{ secrets.CNB_TOKEN }} \
22+
-e PLUGIN_BRANCH="main" \
23+
-e PLUGIN_GIT_USER="cnb" \
24+
-e PLUGIN_GIT_EMAIL="cnb@cnb.cool" \
25+
-e PLUGIN_FORCE="true" \
26+
tencentcom/git-sync

0 commit comments

Comments
 (0)