mirror of
https://github.com/chatfire-AI/huobao-drama.git
synced 2026-08-28 18:07:48 +08:00
chore(docker): 构建换国内镜像源,ffmpeg-static 走 npmmirror,Mysql 端口改 3307
This commit is contained in:
+35
-3
@@ -1,15 +1,45 @@
|
||||
# ── 国内镜像源(可用 --build-arg 覆盖)──────────────────────────
|
||||
# APT_MIRROR: 清华 mirrors.tuna.tsinghua.edu.cn(默认) / 阿里云 mirrors.aliyun.com / 中科大 mirrors.ustc.edu.cn
|
||||
# NPM_REGISTRY: 默认 npmmirror(淘宝源)
|
||||
# pip: 清华 pypi(Stage 2 预置 /etc/pip.conf,装 python 包时自动生效)
|
||||
|
||||
# ── Stage 1: Build frontend ──────────────────────────────────
|
||||
FROM node:20-slim AS frontend-build
|
||||
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
RUN npm config set registry "$NPM_REGISTRY"
|
||||
|
||||
WORKDIR /app/frontend
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY frontend/ ./
|
||||
RUN npm run generate
|
||||
COPY frontend/ ./
|
||||
RUN npm run generate
|
||||
|
||||
# ── Stage 2: Build backend native modules ────────────────────
|
||||
FROM node:20-slim AS backend-build
|
||||
|
||||
ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
|
||||
# apt 换国内源: Debian 12 (bookworm) 是 deb822 格式的 debian.sources,同时兼容旧版 sources.list
|
||||
RUN set -eux; \
|
||||
for f in /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list; do \
|
||||
if [ -f "$f" ]; then \
|
||||
sed -i -e "s|deb.debian.org|${APT_MIRROR}|g" \
|
||||
-e "s|security.debian.org|${APT_MIRROR}|g" "$f"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
# pip 换国内源(当前构建未直接用 pip,预置配置;阿里云: https://mirrors.aliyun.com/pypi/simple/)
|
||||
RUN printf '[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple\n' > /etc/pip.conf
|
||||
|
||||
RUN npm config set registry "$NPM_REGISTRY"
|
||||
|
||||
# ffmpeg-static postinstall 从 GitHub releases 下载二进制,改走 npmmirror 镜像;
|
||||
# disturl 供 node-gyp 下载 node headers 时使用
|
||||
ENV FFMPEG_BINARIES_URL=https://registry.npmmirror.com/-/binary/ffmpeg-static \
|
||||
npm_config_disturl=https://registry.npmmirror.com/-/binary/node
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 make g++ \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
@@ -23,8 +53,10 @@ RUN npm ci --omit=dev
|
||||
# ── Stage 3: Production image (lean) ────────────────────────
|
||||
FROM node:20-slim
|
||||
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
|
||||
# tsx 直接运行 TS 源码;ffmpeg 用 npm 包 ffmpeg-static/ffprobe-static 内置二进制,无需系统安装
|
||||
RUN npm i -g tsx
|
||||
RUN npm config set registry "$NPM_REGISTRY" && npm i -g tsx
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ services:
|
||||
MYSQL_PASSWORD: huobao
|
||||
MYSQL_ROOT_PASSWORD: huobao_root
|
||||
ports:
|
||||
- "3306:3306"
|
||||
- "3307:3306"
|
||||
volumes:
|
||||
- mysql-data:/var/lib/mysql
|
||||
command: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
|
||||
|
||||
Reference in New Issue
Block a user