Files
sub-router/Dockerfile
YANG JIANKUAN 3bdba3e50f feat: 新增 anytls/tuic/hysteria2/socks5 协议解析
新增 anytls、tuic(tuic-v5)、hysteria2、socks5/socks5-tls 解析器,
修复 vmess WebSocket path 处理,并优化 Docker 构建配置。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-23 23:43:35 +08:00

45 lines
1.9 KiB
Docker

FROM node:22-slim AS frontend
# Pin pnpm: corepack otherwise auto-fetches the latest (pnpm 11), which no longer
# reads the "pnpm.onlyBuiltDependencies" field in package.json and fails the build
# on ignored install scripts (esbuild / better-sqlite3). v10 still honors that field.
RUN corepack enable pnpm && corepack prepare pnpm@10.34.3 --activate
WORKDIR /app/web
COPY web/package.json ./
RUN pnpm config set registry https://registry.npmmirror.com && pnpm install
COPY web/ ./
RUN pnpm run build
FROM node:22-slim AS production
# Pin pnpm: corepack otherwise auto-fetches the latest (pnpm 11), which no longer
# reads the "pnpm.onlyBuiltDependencies" field in package.json and fails the build
# on ignored install scripts (esbuild / better-sqlite3). v10 still honors that field.
RUN corepack enable pnpm && corepack prepare pnpm@10.34.3 --activate
WORKDIR /app
# Switch to Aliyun mirror for faster apt downloads in China
RUN sed -i \
-e 's|http://deb.debian.org|http://mirrors.aliyun.com|g' \
-e 's|http://security.debian.org|http://mirrors.aliyun.com|g' \
/etc/apt/sources.list.d/debian.sources
# Build tools needed to compile better-sqlite3 native addon
RUN apt-get update && apt-get install -y python3 make g++ && rm -rf /var/lib/apt/lists/*
COPY server/package.json ./server/
WORKDIR /app/server
# hoisted mode: flat node_modules so native addons (better-sqlite3) can locate their .node files
# pnpm v10 blocks build scripts by default; onlyBuiltDependencies allows better-sqlite3 to compile,
# and explicit rebuild ensures the native addon is built even if install skipped it.
RUN echo "node-linker=hoisted" > .npmrc && \
pnpm config set registry https://registry.npmmirror.com && \
pnpm install --prod && \
pnpm rebuild better-sqlite3
COPY server/ ./
RUN mkdir -p data
COPY --from=frontend /app/web/dist /app/web/dist
EXPOSE 3456
CMD ["pnpm", "exec", "tsx", "src/index.ts"]