update docker config file (#159)

* update dockerfile, use cn mirrors

* deploy: update docker deploy config

更新 docker 配置文件。
1. 切换到 ubuntu,能测试成功;debian 测试有问题,先用 ubuntu 吧。
2. 增加国内源,优化编译+系统安装的速度。
3. 切换成 chrome 浏览器。

* mv docker compose config file

* update docker compose
This commit is contained in:
zy
2025-09-25 23:41:52 +08:00
committed by GitHub
parent f37b4d8591
commit 9fcc7402b6
3 changed files with 69 additions and 29 deletions

View File

@@ -24,7 +24,9 @@
"Bash(gh release list:*)", "Bash(gh release list:*)",
"Bash(awk:*)", "Bash(awk:*)",
"Bash(CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o test-xiaohongshu-mcp-linux-amd64 .)", "Bash(CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o test-xiaohongshu-mcp-linux-amd64 .)",
"Bash(tar:*)" "Bash(tar:*)",
"mcp__playwright__browser_type",
"mcp__playwright__browser_close"
], ],
"deny": [] "deny": []
} }

View File

@@ -2,6 +2,10 @@
FROM golang:1.24 AS builder FROM golang:1.24 AS builder
WORKDIR /src WORKDIR /src
# 配置 Go 模块代理为国内源
ENV GOPROXY=https://goproxy.cn,direct
ENV GOSUMDB=sum.golang.google.cn
COPY go.mod go.sum ./ COPY go.mod go.sum ./
RUN go mod download RUN go mod download
@@ -9,39 +13,72 @@ COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /out/app . RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /out/app .
# ---- run stage ---- # ---- run stage ----
FROM debian:bookworm-slim FROM ubuntu:22.04
# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app WORKDIR /app
# 1. 装 Chromium + 依赖(无头模式运行 rod # 1. 先安装必要工具,然后配置阿里云镜像源
RUN apt-get update && \ RUN apt-get update && apt-get install -y ca-certificates wget gnupg && \
apt-get install -y --no-install-recommends \ sed -i 's|http://archive.ubuntu.com|https://mirrors.aliyun.com|g' /etc/apt/sources.list && \
chromium \ sed -i 's|http://security.ubuntu.com|https://mirrors.aliyun.com|g' /etc/apt/sources.list
# 2. 添加 Google Chrome APT 源并安装 Chrome更稳定的无头浏览器
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg && \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
# 3. 安装 Google Chrome + 依赖(无头模式运行 rod
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \ ca-certificates \
fonts-liberation \ fonts-liberation \
fonts-noto-cjk \
libasound2 \ libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \ libatk-bridge2.0-0 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \ libcups2 \
libdrm2 \ libdbus-1-3 \
libxkbcommon0 \ libexpat1 \
libxcomposite1 \ libfontconfig1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \ libgbm1 \
libpango-1.0-0 \ libgcc1 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \ libnss3 \
libxshmfence1 \ libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
lsb-release \
wget \ wget \
tzdata \ xdg-utils \
google-chrome-stable \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY --from=builder /out/app . COPY --from=builder /out/app .
# 2. 设置默认 Chromium 路径rod 会用) # 4. 创建共享目录并设置权限
ENV ROD_BROWSER_BIN=/usr/bin/chromium RUN mkdir -p /app/images && \
chmod 777 /app/images
# 5. 设置默认 Chrome 路径rod 会用)
ENV ROD_BROWSER_BIN=/usr/bin/google-chrome
EXPOSE 18060 EXPOSE 18060

View File

@@ -6,8 +6,9 @@ services:
tty: true tty: true
volumes: volumes:
- ./data:/app/data - ./data:/app/data
- ./images:/app/images
environment: environment:
- ROD_BROWSER_BIN=/usr/bin/chromium # ← 无头浏览器 - ROD_BROWSER_BIN=/usr/bin/google-chrome
- COOKIES_PATH=/app/data/cookies.json # ← 程序读取/写入这个路径 - COOKIES_PATH=/app/data/cookies.json
ports: ports:
- "18060:18060" - "18060:18060"