Showing
5 changed files
with
22 additions
and
96 deletions
| 1 | 1 | FROM php:8.2-cli |
| 2 | 2 | |
| 3 | +# ----------------------------------------------------------------------------- | |
| 4 | +# 1. 替换 Debian 软件源为阿里云镜像 (加速 apt-get) | |
| 5 | +# 注意:PHP 8.2 官方镜像基于 Debian Bookworm,源文件通常在 /etc/apt/sources.list.d/debian.sources | |
| 6 | +# ----------------------------------------------------------------------------- | |
| 7 | +RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \ | |
| 8 | + sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list | |
| 9 | + | |
| 3 | 10 | # Install dependencies and extensions |
| 4 | -RUN apt-get update && apt-get install -y \ | |
| 11 | +# 增加 --no-install-recommends 减小体积,增加 rm -rf 清理缓存 | |
| 12 | +RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| 5 | 13 | git \ |
| 6 | 14 | unzip \ |
| 7 | 15 | libzip-dev \ |
| 8 | - && docker-php-ext-install pcntl posix sockets zip pdo_mysql | |
| 16 | + && docker-php-ext-install pcntl posix sockets zip pdo_mysql \ | |
| 17 | + && apt-get clean \ | |
| 18 | + && rm -rf /var/lib/apt/lists/* | |
| 9 | 19 | |
| 10 | 20 | # Install Composer |
| 11 | 21 | COPY --from=composer:latest /usr/bin/composer /usr/bin/composer |
| ... | ... | @@ -13,10 +23,16 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer |
| 13 | 23 | # Set working directory |
| 14 | 24 | WORKDIR /app |
| 15 | 25 | |
| 26 | +# ----------------------------------------------------------------------------- | |
| 27 | +# 2. 替换 Composer 镜像源为阿里云镜像 (加速 composer install) | |
| 28 | +# ----------------------------------------------------------------------------- | |
| 29 | +RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ | |
| 30 | + | |
| 16 | 31 | # Copy dependency definition first |
| 17 | 32 | COPY composer.json ./ |
| 33 | +# (Optional) COPY composer.lock ./ | |
| 18 | 34 | |
| 19 | -# Install dependencies (if composer.lock exists it would be better, but we start fresh) | |
| 35 | +# Install dependencies | |
| 20 | 36 | RUN composer install --no-scripts --no-autoloader |
| 21 | 37 | |
| 22 | 38 | # Copy application source |
| ... | ... | @@ -30,3 +46,4 @@ EXPOSE 8888 |
| 30 | 46 | |
| 31 | 47 | # Command to run the Workerman server |
| 32 | 48 | CMD ["php", "start.php", "start"] |
| 49 | + | ... | ... |
docker-compose.prod.yml
deleted
100644 → 0
| 1 | -services: | |
| 2 | - relay: | |
| 3 | - image: moltbot-relay:latest | |
| 4 | - container_name: moltbot-relay | |
| 5 | - ports: | |
| 6 | - - "8888:8888" | |
| 7 | - - "8889:8889" | |
| 8 | - env_file: | |
| 9 | - - .env | |
| 10 | - environment: | |
| 11 | - - REDIS_HOST=redis | |
| 12 | - - REDIS_PORT=6379 | |
| 13 | - | |
| 14 | - redis: | |
| 15 | - image: redis:alpine | |
| 16 | - container_name: moltbot-redis | |
| 17 | - ports: | |
| 18 | - - "6379:6379" |
package-deploy.ps1
deleted
100644 → 0
| 1 | -# Relay Server 部署打包脚本 | |
| 2 | -# 运行: .\package-deploy.ps1 | |
| 3 | - | |
| 4 | -$DeployDir = "$PSScriptRoot\deploy-package" | |
| 5 | -$ZipFile = "$PSScriptRoot\relay-server-deploy.zip" | |
| 6 | - | |
| 7 | -Write-Host "=== 打包 Relay Server 部署文件 ===" -ForegroundColor Cyan | |
| 8 | - | |
| 9 | -# 创建部署目录 | |
| 10 | -if (Test-Path $DeployDir) { Remove-Item $DeployDir -Recurse -Force } | |
| 11 | -New-Item -ItemType Directory -Path $DeployDir | Out-Null | |
| 12 | - | |
| 13 | -# 复制必要文件 | |
| 14 | -$files = @( | |
| 15 | - ".env", | |
| 16 | - "composer.json", | |
| 17 | - "docker-compose.yml", | |
| 18 | - "Dockerfile", | |
| 19 | - "migrate.php", | |
| 20 | - "start.php" | |
| 21 | -) | |
| 22 | - | |
| 23 | -foreach ($file in $files) { | |
| 24 | - Copy-Item "$PSScriptRoot\$file" "$DeployDir\" -Force | |
| 25 | - Write-Host " + $file" -ForegroundColor Green | |
| 26 | -} | |
| 27 | - | |
| 28 | -# 创建部署说明 | |
| 29 | -$readme = @" | |
| 30 | -# Relay Server 部署指南 | |
| 31 | - | |
| 32 | -## 1. 上传整个目录到服务器 | |
| 33 | - scp -r . user@server:/opt/moltbot-relay | |
| 34 | - | |
| 35 | -## 2. 修改 .env 配置 | |
| 36 | - - DB_HOST: 数据库地址 | |
| 37 | - - DB_PASSWORD: 数据库密码 | |
| 38 | - - REDIS_HOST: Redis 地址(使用 docker 内部网络可设为 redis) | |
| 39 | - | |
| 40 | -## 3. 启动服务 | |
| 41 | - cd /opt/moltbot-relay | |
| 42 | - docker-compose up -d --build | |
| 43 | - | |
| 44 | -## 4. 查看日志 | |
| 45 | - docker-compose logs -f | |
| 46 | - | |
| 47 | -## 5. 开放防火墙 | |
| 48 | - firewall-cmd --permanent --add-port=8888/tcp | |
| 49 | - firewall-cmd --reload | |
| 50 | - | |
| 51 | -## 6. 修改本地插件配置 | |
| 52 | - 编辑 ~/.clawdbot/clawdbot.json: | |
| 53 | - { | |
| 54 | - "channels": { | |
| 55 | - "wechat": { | |
| 56 | - "enabled": true, | |
| 57 | - "relayUrl": "ws://服务器IP:8888" | |
| 58 | - } | |
| 59 | - } | |
| 60 | - } | |
| 61 | -"@ | |
| 62 | -$readme | Set-Content "$DeployDir\README.md" -Encoding UTF8 | |
| 63 | - | |
| 64 | -# 打包成 zip | |
| 65 | -if (Test-Path $ZipFile) { Remove-Item $ZipFile -Force } | |
| 66 | -Compress-Archive -Path "$DeployDir\*" -DestinationPath $ZipFile | |
| 67 | - | |
| 68 | -Write-Host "" | |
| 69 | -Write-Host "=== 打包完成 ===" -ForegroundColor Green | |
| 70 | -Write-Host "部署包: $ZipFile" -ForegroundColor Yellow | |
| 71 | -Write-Host "" | |
| 72 | -Write-Host "将 zip 文件上传到服务器后解压并运行 docker-compose up -d --build" -ForegroundColor White | |
| 73 | - | |
| 74 | -# 清理临时目录 | |
| 75 | -Remove-Item $DeployDir -Recurse -Force |
relay-server-deploy.zip
deleted
100644 → 0
No preview for this file type
Please
register
or
login
to post a comment