Skip to content

Commit 3323dd5

Browse files
authored
ci(docker): publish official Docker Hub image (#51)
1 parent 533c2ce commit 3323dd5

5 files changed

Lines changed: 118 additions & 24 deletions

File tree

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ go.sum merge=union
1717
.gitattributes merge=ours
1818
README-ccs-fork.md merge=ours
1919

20-
# Image references diverge from upstream (Plus publishes to
21-
# ghcr.io/kaitranntt/cli-proxy-api-plus, upstream publishes to
20+
# Image references diverge from upstream (Plus publishes official images to
21+
# kaitranntt/cli-proxy-api-plus with a GHCR mirror; upstream publishes to
2222
# eceasy/cli-proxy-api). Keep ours so upstream sync does not silently revert
2323
# the image path back to upstream's.
2424
docker-compose.yml merge=ours

.github/workflows/docker-image.yml

Lines changed: 73 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: docker-image
22

3-
# Builds and publishes the multi-arch Docker image for CLIProxyAPIPlus to GHCR.
3+
# Builds and publishes the multi-arch Docker image for CLIProxyAPIPlus.
44
#
55
# Triggers:
66
# - push of any v* tag (works when a PAT pushes the tag; sync-release-tag.yml
@@ -11,8 +11,10 @@ name: docker-image
1111
# Runner: self-hosted `cliproxy` (docker host LXC). QEMU + buildx produce both
1212
# linux/amd64 and linux/arm64 from a single x64 host.
1313
#
14-
# Registry: ghcr.io/<owner>/cli-proxy-api-plus. Auth uses the built-in
15-
# GITHUB_TOKEN — no Docker Hub credentials required.
14+
# Registries:
15+
# - GHCR: ghcr.io/<owner>/cli-proxy-api-plus using built-in GITHUB_TOKEN
16+
# - Docker Hub: kaitranntt/cli-proxy-api-plus when DOCKERHUB_TOKEN is
17+
# configured (DOCKERHUB_USERNAME is optional; defaults to kaitranntt)
1618

1719
on:
1820
workflow_dispatch:
@@ -27,8 +29,9 @@ on:
2729

2830
env:
2931
APP_NAME: CLIProxyAPI
30-
REGISTRY: ghcr.io
31-
IMAGE_NAME: ${{ github.repository_owner }}/cli-proxy-api-plus
32+
GHCR_REGISTRY: ghcr.io
33+
GHCR_IMAGE_NAME: ${{ github.repository_owner }}/cli-proxy-api-plus
34+
DOCKERHUB_IMAGE_NAME: kaitranntt/cli-proxy-api-plus
3235

3336
permissions:
3437
contents: read
@@ -71,16 +74,38 @@ jobs:
7174
- name: Login to GHCR
7275
uses: docker/login-action@v3
7376
with:
74-
registry: ${{ env.REGISTRY }}
77+
registry: ${{ env.GHCR_REGISTRY }}
7578
username: ${{ github.actor }}
7679
password: ${{ secrets.GITHUB_TOKEN }}
7780

78-
- name: Lowercase image name
81+
- name: Detect Docker Hub credentials
82+
id: dockerhub
83+
env:
84+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
85+
run: |
86+
if [ -n "${DOCKERHUB_TOKEN}" ]; then
87+
echo "enabled=true" >> "$GITHUB_OUTPUT"
88+
else
89+
echo "enabled=false" >> "$GITHUB_OUTPUT"
90+
fi
91+
92+
- name: Login to Docker Hub
93+
if: steps.dockerhub.outputs.enabled == 'true'
94+
uses: docker/login-action@v3
95+
with:
96+
username: ${{ secrets.DOCKERHUB_USERNAME || 'kaitranntt' }}
97+
password: ${{ secrets.DOCKERHUB_TOKEN }}
98+
99+
- name: Lowercase image names
79100
id: img
80101
run: |
81-
IMG="${REGISTRY}/${IMAGE_NAME}"
82-
IMG_LC="$(echo "${IMG}" | tr '[:upper:]' '[:lower:]')"
83-
echo "ref=${IMG_LC}" >> "$GITHUB_OUTPUT"
102+
GHCR_IMG="${GHCR_REGISTRY}/${GHCR_IMAGE_NAME}"
103+
GHCR_IMG_LC="$(echo "${GHCR_IMG}" | tr '[:upper:]' '[:lower:]')"
104+
DOCKERHUB_IMG_LC="$(echo "${DOCKERHUB_IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')"
105+
{
106+
echo "ghcr_ref=${GHCR_IMG_LC}"
107+
echo "dockerhub_ref=${DOCKERHUB_IMG_LC}"
108+
} >> "$GITHUB_OUTPUT"
84109
85110
- name: Build metadata
86111
id: meta
@@ -94,6 +119,25 @@ jobs:
94119
echo "build_date=${BUILD_DATE}"
95120
} >> "$GITHUB_OUTPUT"
96121
122+
- name: Build tag list
123+
id: tags
124+
env:
125+
GHCR_REF: ${{ steps.img.outputs.ghcr_ref }}
126+
DOCKERHUB_REF: ${{ steps.img.outputs.dockerhub_ref }}
127+
VERSION: ${{ steps.meta.outputs.version }}
128+
DOCKERHUB_ENABLED: ${{ steps.dockerhub.outputs.enabled }}
129+
run: |
130+
{
131+
echo "tags<<EOF"
132+
echo "${GHCR_REF}:${VERSION}"
133+
echo "${GHCR_REF}:latest"
134+
if [ "${DOCKERHUB_ENABLED}" = "true" ]; then
135+
echo "${DOCKERHUB_REF}:${VERSION}"
136+
echo "${DOCKERHUB_REF}:latest"
137+
fi
138+
echo "EOF"
139+
} >> "$GITHUB_OUTPUT"
140+
97141
- name: Build and push (multi-arch)
98142
uses: docker/build-push-action@v6
99143
with:
@@ -104,16 +148,28 @@ jobs:
104148
VERSION=${{ steps.meta.outputs.version }}
105149
COMMIT=${{ steps.meta.outputs.commit }}
106150
BUILD_DATE=${{ steps.meta.outputs.build_date }}
107-
tags: |
108-
${{ steps.img.outputs.ref }}:${{ steps.meta.outputs.version }}
109-
${{ steps.img.outputs.ref }}:latest
151+
tags: ${{ steps.tags.outputs.tags }}
110152

111153
- name: Summary
154+
env:
155+
GHCR_REF: ${{ steps.img.outputs.ghcr_ref }}
156+
DOCKERHUB_REF: ${{ steps.img.outputs.dockerhub_ref }}
157+
VERSION: ${{ steps.meta.outputs.version }}
158+
DOCKERHUB_ENABLED: ${{ steps.dockerhub.outputs.enabled }}
112159
run: |
113160
{
114161
echo "## Published"
115-
echo "- \`${{ steps.img.outputs.ref }}:${{ steps.meta.outputs.version }}\`"
116-
echo "- \`${{ steps.img.outputs.ref }}:latest\`"
117-
echo
118-
echo "Pull: \`docker pull ${{ steps.img.outputs.ref }}:${{ steps.meta.outputs.version }}\`"
162+
echo "- \`${GHCR_REF}:${VERSION}\`"
163+
echo "- \`${GHCR_REF}:latest\`"
164+
if [ "${DOCKERHUB_ENABLED}" = "true" ]; then
165+
echo "- \`${DOCKERHUB_REF}:${VERSION}\`"
166+
echo "- \`${DOCKERHUB_REF}:latest\`"
167+
echo
168+
echo "Pull: \`docker pull ${DOCKERHUB_REF}:${VERSION}\`"
169+
else
170+
echo
171+
echo "Docker Hub skipped: configure \`DOCKERHUB_TOKEN\` to publish \`${DOCKERHUB_REF}\`. Set \`DOCKERHUB_USERNAME\` only if the login account is not \`kaitranntt\`."
172+
echo
173+
echo "Pull: \`docker pull ${GHCR_REF}:${VERSION}\`"
174+
fi
119175
} >> "$GITHUB_STEP_SUMMARY"

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,33 @@ CLIProxyAPI Guides: [https://help.router-for.me/](https://help.router-for.me/)
7272

7373
### Run with Docker
7474

75-
Multi-arch images (`linux/amd64`, `linux/arm64`) are published to GitHub Container Registry on every release tag.
75+
Multi-arch images (`linux/amd64`, `linux/arm64`) are published to Docker Hub and GitHub Container Registry on every release tag.
7676

7777
```sh
7878
# Pull a specific version (recommended)
79-
docker pull ghcr.io/kaitranntt/cli-proxy-api-plus:v6.9.45-0
79+
docker pull kaitranntt/cli-proxy-api-plus:v6.9.45-0
8080

8181
# Or pull the latest published release
82+
docker pull kaitranntt/cli-proxy-api-plus:latest
83+
```
84+
85+
GHCR mirror:
86+
87+
```sh
8288
docker pull ghcr.io/kaitranntt/cli-proxy-api-plus:latest
8389
```
8490

85-
Or use the included `docker-compose.yml` (defaults to the GHCR image, builds from source if `CLI_PROXY_IMAGE` is overridden):
91+
Or use the included `docker-compose.yml` (defaults to the Docker Hub image, builds from source if `CLI_PROXY_IMAGE` is overridden):
8692

8793
```sh
8894
git clone https://github.com/kaitranntt/CLIProxyAPIPlus.git
8995
cd CLIProxyAPIPlus
9096
docker compose up -d
9197
```
9298

93-
Available tags: [`ghcr.io/kaitranntt/cli-proxy-api-plus`](https://github.com/kaitranntt/CLIProxyAPIPlus/pkgs/container/cli-proxy-api-plus).
99+
Available tags:
100+
- Docker Hub: [`kaitranntt/cli-proxy-api-plus`](https://hub.docker.com/r/kaitranntt/cli-proxy-api-plus)
101+
- GHCR: [`ghcr.io/kaitranntt/cli-proxy-api-plus`](https://github.com/kaitranntt/CLIProxyAPIPlus/pkgs/container/cli-proxy-api-plus)
94102

95103
## Management API
96104

README_CN.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,36 @@ VisionCoder 还为我们的用户提供 <a href="https://coder.visioncoder.cn" t
7070

7171
CLIProxyAPI 用户手册: [https://help.router-for.me/](https://help.router-for.me/cn/)
7272

73+
### 使用 Docker 运行
74+
75+
每个发布标签都会发布多架构镜像(`linux/amd64``linux/arm64`)到 Docker Hub 和 GitHub Container Registry。
76+
77+
```sh
78+
# 拉取指定版本(推荐)
79+
docker pull kaitranntt/cli-proxy-api-plus:v6.9.45-0
80+
81+
# 或拉取最新发布版本
82+
docker pull kaitranntt/cli-proxy-api-plus:latest
83+
```
84+
85+
GHCR 镜像:
86+
87+
```sh
88+
docker pull ghcr.io/kaitranntt/cli-proxy-api-plus:latest
89+
```
90+
91+
也可以使用仓库内置的 `docker-compose.yml`(默认使用 Docker Hub 镜像;如需覆盖,可设置 `CLI_PROXY_IMAGE`):
92+
93+
```sh
94+
git clone https://github.com/kaitranntt/CLIProxyAPIPlus.git
95+
cd CLIProxyAPIPlus
96+
docker compose up -d
97+
```
98+
99+
可用标签:
100+
- Docker Hub: [`kaitranntt/cli-proxy-api-plus`](https://hub.docker.com/r/kaitranntt/cli-proxy-api-plus)
101+
- GHCR: [`ghcr.io/kaitranntt/cli-proxy-api-plus`](https://github.com/kaitranntt/CLIProxyAPIPlus/pkgs/container/cli-proxy-api-plus)
102+
73103
## 管理 API 文档
74104

75105
请参见 [MANAGEMENT_API_CN.md](https://help.router-for.me/cn/management/api)

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
cli-proxy-api:
3-
image: ${CLI_PROXY_IMAGE:-ghcr.io/kaitranntt/cli-proxy-api-plus:latest}
3+
image: ${CLI_PROXY_IMAGE:-kaitranntt/cli-proxy-api-plus:latest}
44
pull_policy: always
55
build:
66
context: .

0 commit comments

Comments
 (0)