mirror of
https://github.com/isboyjc/GoProxy.git
synced 2026-07-12 16:02:14 +08:00
fix: 🐛 update README and Docker setup documentation for GitHub Container Registry support
This commit is contained in:
42
.github/DOCKER_SETUP.md
vendored
42
.github/DOCKER_SETUP.md
vendored
@@ -10,9 +10,19 @@
|
|||||||
|
|
||||||
## 🔧 配置 GitHub Secrets
|
## 🔧 配置 GitHub Secrets
|
||||||
|
|
||||||
### 1. Docker Hub 配置(可选)
|
### GitHub Container Registry(默认已配置)✅
|
||||||
|
|
||||||
如果要推送到 Docker Hub,需要配置以下 Secrets:
|
GitHub Container Registry (ghcr.io) **无需任何配置**,workflow 会自动推送:
|
||||||
|
|
||||||
|
- **镜像地址**:`ghcr.io/isboyjc/goproxy`
|
||||||
|
- **认证方式**:自动使用 `GITHUB_TOKEN`
|
||||||
|
- **推送策略**:每次构建都会推送
|
||||||
|
|
||||||
|
### Docker Hub 配置(可选)⚙️
|
||||||
|
|
||||||
|
Docker Hub 配置是**可选的**,如果不配置,workflow 会自动跳过 Docker Hub 推送,**不会影响 GHCR 构建**。
|
||||||
|
|
||||||
|
**如需推送到 Docker Hub**,按以下步骤配置:
|
||||||
|
|
||||||
1. 登录 [Docker Hub](https://hub.docker.com/)
|
1. 登录 [Docker Hub](https://hub.docker.com/)
|
||||||
2. 在 **Account Settings > Security** 创建 Access Token
|
2. 在 **Account Settings > Security** 创建 Access Token
|
||||||
@@ -20,11 +30,9 @@
|
|||||||
- `DOCKERHUB_USERNAME`: 你的 Docker Hub 用户名
|
- `DOCKERHUB_USERNAME`: 你的 Docker Hub 用户名
|
||||||
- `DOCKERHUB_TOKEN`: 刚才创建的 Access Token
|
- `DOCKERHUB_TOKEN`: 刚才创建的 Access Token
|
||||||
|
|
||||||
### 2. GitHub Container Registry(默认已配置)
|
配置完成后,workflow 会同时推送到两个仓库:
|
||||||
|
- `docker.io/isboyjc/goproxy`
|
||||||
GitHub Container Registry (ghcr.io) 无需额外配置,workflow 使用自动提供的 `GITHUB_TOKEN`。
|
- `ghcr.io/isboyjc/goproxy`
|
||||||
|
|
||||||
**镜像地址**:`ghcr.io/isboyjc/goproxy`
|
|
||||||
|
|
||||||
## 🏗️ 构建特性
|
## 🏗️ 构建特性
|
||||||
|
|
||||||
@@ -120,8 +128,26 @@ docker run -d \
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 🔄 构建策略
|
||||||
|
|
||||||
|
Workflow 使用**分离构建策略**:
|
||||||
|
|
||||||
|
1. **GHCR 构建**(总是执行):
|
||||||
|
- 无需任何配置,自动推送到 `ghcr.io/isboyjc/goproxy`
|
||||||
|
- 使用内置的 `GITHUB_TOKEN`
|
||||||
|
- 即使 Docker Hub 未配置也不受影响
|
||||||
|
|
||||||
|
2. **Docker Hub 构建**(可选):
|
||||||
|
- 仅在配置了 `DOCKERHUB_USERNAME` 和 `DOCKERHUB_TOKEN` secrets 时执行
|
||||||
|
- 未配置时自动跳过,不会报错
|
||||||
|
|
||||||
|
**优势**:
|
||||||
|
- ✅ 零配置即可使用(通过 GHCR)
|
||||||
|
- ✅ Docker Hub 完全可选
|
||||||
|
- ✅ 构建失败不会影响另一个仓库
|
||||||
|
|
||||||
## 📝 注意事项
|
## 📝 注意事项
|
||||||
|
|
||||||
- **权限配置**:首次推送到 GHCR 可能需要在仓库 **Settings > Actions > General** 中设置 **Workflow permissions** 为 `Read and write permissions`
|
- **权限配置**:首次推送到 GHCR 可能需要在仓库 **Settings > Actions > General** 中设置 **Workflow permissions** 为 `Read and write permissions`
|
||||||
- **GHCR 可见性**:默认镜像为私有,可在 **Packages** 页面修改为公开
|
- **GHCR 可见性**:默认镜像为私有,可在 **Packages** 页面修改为公开
|
||||||
- **Docker Hub 可选**:如果不需要推送到 Docker Hub,可在 workflow 文件中删除相关配置,或不配置 DOCKERHUB_* secrets(workflow 会跳过 Docker Hub 登录失败的步骤)
|
- **Docker Hub 可选**:不配置 Docker Hub secrets 不会影响构建,workflow 会自动跳过
|
||||||
|
|||||||
40
.github/workflows/docker-image.yml
vendored
40
.github/workflows/docker-image.yml
vendored
@@ -30,13 +30,24 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Extract metadata
|
- name: Extract metadata for GHCR
|
||||||
id: meta
|
id: meta-ghcr
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: ${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
|
||||||
${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }}
|
tags: |
|
||||||
${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Extract metadata for Docker Hub
|
||||||
|
id: meta-dockerhub
|
||||||
|
if: secrets.DOCKERHUB_USERNAME != ''
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
@@ -45,7 +56,7 @@ jobs:
|
|||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && secrets.DOCKERHUB_USERNAME != ''
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY_DOCKERHUB }}
|
registry: ${{ env.REGISTRY_DOCKERHUB }}
|
||||||
@@ -60,13 +71,24 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push to GHCR
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta-ghcr.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta-ghcr.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
- name: Build and push to Docker Hub
|
||||||
|
if: github.event_name != 'pull_request' && secrets.DOCKERHUB_USERNAME != ''
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta-dockerhub.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta-dockerhub.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
|||||||
22
README.md
22
README.md
@@ -244,17 +244,9 @@ docker compose up -d
|
|||||||
# http://localhost:7778(默认密码:goproxy)
|
# http://localhost:7778(默认密码:goproxy)
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 Docker Hub 镜像
|
### 使用预构建镜像(docker run)
|
||||||
|
|
||||||
```bash
|
**推荐使用 GitHub Container Registry**(自动构建,无需额外配置):
|
||||||
docker pull isboyjc/goproxy:latest
|
|
||||||
docker run -d --name proxygo \
|
|
||||||
-p 127.0.0.1:7776:7776 -p 127.0.0.1:7777:7777 -p 7778:7778 \
|
|
||||||
-e WEBUI_PASSWORD=your_password -v "$(pwd)/data:/app/data" \
|
|
||||||
isboyjc/goproxy:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
### 使用 GitHub Container Registry 镜像
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker pull ghcr.io/isboyjc/goproxy:latest
|
docker pull ghcr.io/isboyjc/goproxy:latest
|
||||||
@@ -264,6 +256,16 @@ docker run -d --name proxygo \
|
|||||||
ghcr.io/isboyjc/goproxy:latest
|
ghcr.io/isboyjc/goproxy:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**或使用 Docker Hub**(如果已配置):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull isboyjc/goproxy:latest
|
||||||
|
docker run -d --name proxygo \
|
||||||
|
-p 127.0.0.1:7776:7776 -p 127.0.0.1:7777:7777 -p 7778:7778 \
|
||||||
|
-e WEBUI_PASSWORD=your_password -v "$(pwd)/data:/app/data" \
|
||||||
|
isboyjc/goproxy:latest
|
||||||
|
```
|
||||||
|
|
||||||
### 环境变量配置
|
### 环境变量配置
|
||||||
|
|
||||||
**核心配置**(`.env` 文件):
|
**核心配置**(`.env` 文件):
|
||||||
|
|||||||
Reference in New Issue
Block a user