Skip to content

Commit 07281cf

Browse files
eryajferyajf
authored andcommitted
build: 移除DockerHub相关配置,添加GitHub容器注册表支持
1 parent fbd78b1 commit 07281cf

File tree

3 files changed

+53
-53
lines changed

3 files changed

+53
-53
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ main:
1717
- name: 🐋 推送镜像
1818
timeout: 3h
1919
script: |
20-
echo ${DOCKERHUB_TOKEN} | docker login -u ${DOCKERHUB_USERNAME} --password-stdin
2120
echo ${ALIHUB_TOKEN} | docker login -u ${ALIHUB_USERNAME} --password-stdin ${ALIHUB_URL}
2221
docker run -d --name buildkitd \
2322
--security-opt seccomp=unconfined \
@@ -28,8 +27,6 @@ main:
2827
--name mybuilder \
2928
--driver remote docker-container://buildkitd
3029
docker buildx build \
31-
-t ${DOCKERHUB_USERNAME}/${IMAGE_NAME} \
32-
-t ${DOCKERHUB_USERNAME}/${IMAGE_NAME}:${CNB_BRANCH}_`date "+%Y%m%d%H%M%S"` \
3330
-t ${ALIHUB_URL}/${ALIHUB_USERNAME}/${IMAGE_NAME} \
3431
-t ${ALIHUB_URL}/${ALIHUB_USERNAME}/${IMAGE_NAME}:${CNB_BRANCH}_`date "+%Y%m%d%H%M%S"` \
3532
-t ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE} \

.cnb/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ $:
1515
- name: 🐋 推送镜像
1616
timeout: 3h
1717
script: |
18-
docker login -u ${DOCKERHUB_USERNAME} -p ${DOCKERHUB_TOKEN}
1918
docker login -u ${ALIHUB_USERNAME} -p ${ALIHUB_TOKEN} ${ALIHUB_URL}
2019
docker run -d --name buildkitd \
2120
--security-opt seccomp=unconfined \
@@ -26,8 +25,6 @@ $:
2625
--name mybuilder \
2726
--driver remote docker-container://buildkitd
2827
docker buildx build \
29-
-t ${DOCKERHUB_USERNAME}/${IMAGE_NAME} \
30-
-t ${DOCKERHUB_USERNAME}/${IMAGE_NAME}:${CNB_BRANCH}_`date "+%Y%m%d%H%M%S"` \
3128
-t ${ALIHUB_URL}/${ALIHUB_USERNAME}/${IMAGE_NAME} \
3229
-t ${ALIHUB_URL}/${ALIHUB_USERNAME}/${IMAGE_NAME}:${CNB_BRANCH}_`date "+%Y%m%d%H%M%S"` \
3330
-t ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE} \

.github/workflows/build-docker-image.yml

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,58 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- uses: actions/checkout@v4
33-
# - name: Inject slug/short variables
34-
# uses: rlespinasse/github-slug-action@v4
35-
# - name: Get current date
36-
# id: date
37-
# run: echo "today=$(date +'%Y%m%d-%H%M')" >> $GITHUB_OUTPUT
38-
# - name: Set up QEMU
39-
# uses: docker/setup-qemu-action@v3
40-
# - name: Set up Docker Buildx
41-
# uses: docker/setup-buildx-action@v3
42-
# - name: Login to DockerHub
43-
# uses: docker/login-action@v3
44-
# with:
45-
# username: ${{ env.DOCKERHUB_USERNAME }}
46-
# password: ${{ secrets.DOCKERHUB_TOKEN }}
47-
# - name: Login to the Ali Registry
48-
# uses: docker/login-action@v3
49-
# with:
50-
# registry: ${{ env.ALIHUB_URL }}
51-
# username: ${{ env.ALIHUB_USERNAME }}
52-
# password: ${{ secrets.ALIHUB_TOKEN }}
33+
- name: Inject slug/short variables
34+
uses: rlespinasse/github-slug-action@v4
35+
- name: Get current date
36+
id: date
37+
run: echo "today=$(date +'%Y%m%d-%H%M')" >> $GITHUB_OUTPUT
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v3
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
- name: Login to DockerHub
43+
uses: docker/login-action@v3
44+
with:
45+
username: ${{ env.DOCKERHUB_USERNAME }}
46+
password: ${{ secrets.DOCKERHUB_TOKEN }}
47+
- name: Login to GitHub Container Registry
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
# - name: Login to the Ali Registry
54+
# uses: docker/login-action@v3
55+
# with:
56+
# registry: ${{ env.ALIHUB_URL }}
57+
# username: ${{ env.ALIHUB_USERNAME }}
58+
# password: ${{ secrets.ALIHUB_TOKEN }}
5359

54-
# - name: 设置go环境
55-
# uses: actions/setup-go@v5
56-
# with:
57-
# go-version-file: "go.mod"
58-
# cache-dependency-path: "go.sum"
59-
# - name: 安装 UPX
60-
# uses: crazy-max/ghaction-upx@v3
61-
# with:
62-
# install-only: true
63-
# - run: go install github.com/authelia/gox@latest # setup gox
64-
# - run: make gox-linux
60+
# - name: 设置go环境
61+
# uses: actions/setup-go@v5
62+
# with:
63+
# go-version-file: "go.mod"
64+
# cache-dependency-path: "go.sum"
65+
# - name: 安装 UPX
66+
# uses: crazy-max/ghaction-upx@v3
67+
# with:
68+
# install-only: true
69+
# - run: go install github.com/authelia/gox@latest # setup gox
70+
# - run: make gox-linux
6571

66-
# - name: Build and push
67-
# uses: docker/build-push-action@v6
68-
# with:
69-
# context: .
70-
# file: ./Dockerfile
71-
# push: ${{ github.event_name != 'pull_request' }}
72-
# cache-from: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:buildcache
73-
# cache-to: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:buildcache,mode=max
74-
# platforms: linux/amd64,linux/arm64
75-
# tags: |
76-
# ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:latest
77-
# ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:${{ env.GITHUB_REF_NAME }}
78-
# ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:${{ steps.date.outputs.today }}
79-
# ${{ env.ALIHUB_URL }}/${{ env.ALIHUB_IMAGE_REPONAME }}/${{ env.IMAGE_REPONAME }}:latest
80-
# ${{ env.ALIHUB_URL }}/${{ env.ALIHUB_IMAGE_REPONAME }}/${{ env.IMAGE_REPONAME }}:${{ env.GITHUB_REF_NAME }}
81-
# ${{ env.ALIHUB_URL }}/${{ env.ALIHUB_IMAGE_REPONAME }}/${{ env.IMAGE_REPONAME }}:${{ steps.date.outputs.today }}
72+
- name: Build and push
73+
uses: docker/build-push-action@v6
74+
with:
75+
context: .
76+
file: ./Dockerfile
77+
push: ${{ github.event_name != 'pull_request' }}
78+
cache-from: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:buildcache
79+
cache-to: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:buildcache,mode=max
80+
platforms: linux/amd64,linux/arm64
81+
tags: |
82+
${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:latest
83+
${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:${{ env.GITHUB_REF_NAME }}
84+
${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_REPONAME }}:${{ steps.date.outputs.today }}
85+
ghcr.io/${{ github.actor }}/${{ github.repository }}
86+
ghcr.io/${{ github.actor }}/${{ github.repository }}:${{ env.GITHUB_REF_NAME }}
87+
ghcr.io/${{ github.actor }}/${{ github.repository }}:${{ steps.date.outputs.today }}

0 commit comments

Comments
 (0)