docs: rewrite Docker Compose deployment guide with copy-paste commands
Build and Push to GHCR / build-and-push (push) Has been cancelled
Build and Push to GHCR / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -33,48 +33,70 @@ LISTEN_ADDR=:9090 ./mirror-proxy
|
|||||||
|
|
||||||
## Docker 部署
|
## Docker 部署
|
||||||
|
|
||||||
### 使用 Docker 直接运行
|
### 使用 Docker Compose(推荐)
|
||||||
|
|
||||||
|
无需克隆仓库,一条命令即可完成部署。
|
||||||
|
|
||||||
|
**1. 创建 `docker-compose.yml`**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 构建镜像
|
cat > docker-compose.yml << 'EOF'
|
||||||
docker build -t mirror-proxy .
|
services:
|
||||||
|
mirror-proxy:
|
||||||
# 运行容器(首次运行会自动创建 config.json)
|
image: ghcr.io/arkylin/mirror-proxy:latest
|
||||||
docker run -d \
|
container_name: mirror-proxy
|
||||||
--name mirror-proxy \
|
restart: unless-stopped
|
||||||
-p 8080:8080 \
|
ports:
|
||||||
-v $(pwd)/config.json:/app/config.json \
|
- "8080:8080"
|
||||||
-v $(pwd)/cache:/app/cache \
|
volumes:
|
||||||
--restart unless-stopped \
|
- ./config.json:/app/config.json
|
||||||
mirror-proxy
|
- ./cache:/app/cache
|
||||||
|
environment:
|
||||||
|
- TZ=Asia/Shanghai
|
||||||
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 Docker Compose
|
**2. 启动服务**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 启动服务
|
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
首次启动会自动创建 `config.json`(默认账号 `admin` / `admin123`)。
|
||||||
|
|
||||||
|
**3. 常用命令**
|
||||||
|
|
||||||
|
```bash
|
||||||
# 查看日志
|
# 查看日志
|
||||||
docker-compose logs -f
|
docker-compose logs -f
|
||||||
|
|
||||||
|
# 查看运行状态
|
||||||
|
docker-compose ps
|
||||||
|
|
||||||
# 停止服务
|
# 停止服务
|
||||||
docker-compose down
|
docker-compose down
|
||||||
|
|
||||||
|
# 重启服务
|
||||||
|
docker-compose restart
|
||||||
|
|
||||||
|
# 更新到最新镜像
|
||||||
|
docker-compose pull && docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
`docker-compose.yml` 已包含端口映射和卷挂载:
|
**4. 管理后台**
|
||||||
- `./config.json:/app/config.json` — 配置文件持久化
|
|
||||||
- `./cache:/app/cache` — 缓存目录持久化
|
|
||||||
|
|
||||||
### 使用 GHCR 镜像(免构建)
|
访问 `http://<服务器IP>:8080/admin/`,默认账号:
|
||||||
|
- 用户名:`admin`
|
||||||
|
- 密码:`admin123`
|
||||||
|
|
||||||
每次 push 到 `main` 分支或打 `v*` 标签时,会自动构建并推送镜像到 GHCR。
|
> 建议首次登录后立即在 **系统设置** 中修改密码。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 使用 Docker 直接运行
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 拉取最新镜像
|
# 拉取并运行(首次运行自动生成 config.json)
|
||||||
docker pull ghcr.io/arkylin/mirror-proxy:latest
|
|
||||||
|
|
||||||
# 运行
|
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name mirror-proxy \
|
--name mirror-proxy \
|
||||||
-p 8080:8080 \
|
-p 8080:8080 \
|
||||||
@@ -84,6 +106,18 @@ docker run -d \
|
|||||||
ghcr.io/arkylin/mirror-proxy:latest
|
ghcr.io/arkylin/mirror-proxy:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 自行构建镜像
|
||||||
|
|
||||||
|
如需本地构建:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 克隆仓库后执行
|
||||||
|
docker build -t mirror-proxy .
|
||||||
|
docker run -d --name mirror-proxy -p 8080:8080 mirror-proxy
|
||||||
|
```
|
||||||
|
|
||||||
## 使用方式
|
## 使用方式
|
||||||
|
|
||||||
### 1. Docker Hub / GHCR(daemon.json 方式)
|
### 1. Docker Hub / GHCR(daemon.json 方式)
|
||||||
|
|||||||
Reference in New Issue
Block a user