mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-01 20:42:50 +08:00
better-sqlite3 stopped publishing prebuilt binaries for Node 20's ABI
(115) in 12.10.0 - upstream, not a mirror gap:
12.8.0 / 12.9.0 115 127 131 137 141
12.10.0+ 127 137 141 147
`better-sqlite3: ^12.8.0` resolves well past that, so every Node 20
install 404'd on the CDN, fell through to the source build, and demanded
Python plus a C++ toolchain before the bot could start at all. package.json
went on claiming `^20.19.0` worked, and the README went on recommending
Node 20 as one of two blessed versions. It was not a supported
configuration in any meaningful sense - it was a trap.
So say so up front: engines, both setup scripts, and the Docker images now
require Node 22.12+ (or 24+, which still needs a source build for opus).
The version gate in setup.bat / setup.sh is kept byte-identical to the
engines range, as before.
Also copy scripts/lib/console-log.mjs into the production image. The
previous commit had check-native.mjs import it, and the Dockerfile copies
check-native.mjs in on its own for `docker exec ... npm start` - without
its dependency that preflight now dies with ERR_MODULE_NOT_FOUND.
BREAKING CHANGE: Node 20 is no longer supported. Node 22.12 LTS or newer
is required; setup refuses to run on anything older.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
68 lines
2.3 KiB
Docker
68 lines
2.3 KiB
Docker
# ==========================================
|
|
# TSMusicBot Docker Image
|
|
# One-click deployment — all dependencies included
|
|
# ==========================================
|
|
|
|
# --- Stage 1: Build backend + frontend ---
|
|
FROM node:22-slim AS builder
|
|
|
|
# Install build tools for native modules (opus, better-sqlite3)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3 make g++ && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Install backend dependencies
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# Install frontend dependencies
|
|
COPY web/package*.json ./web/
|
|
RUN cd web && npm ci
|
|
|
|
# Copy source and build
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Install production dependencies (with native addons compiled) in the builder
|
|
# so we don't need build tools in the production image.
|
|
RUN rm -rf node_modules && npm ci --production && npm cache clean --force
|
|
|
|
# --- Stage 2: Production image ---
|
|
FROM node:22-slim
|
|
|
|
# Install system FFmpeg — the ffmpeg-static npm package bundles a pre-compiled
|
|
# binary that can SIGSEGV inside Docker (incompatible glibc / missing libs).
|
|
# System-installed FFmpeg is always compatible with the container runtime.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ffmpeg && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy built output and pre-compiled production node_modules from builder
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/web/dist ./web/dist
|
|
COPY --from=builder /app/package*.json ./
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
# package.json declares a `prestart` preflight, so `npm start` inside the
|
|
# container needs this file. The image's own CMD calls node directly and never
|
|
# goes through npm, but an interactive `docker exec ... npm start` would
|
|
# otherwise die on a missing script rather than starting the bot.
|
|
COPY --from=builder /app/scripts/check-native.mjs ./scripts/check-native.mjs
|
|
# ...and the module it imports for crash-proof logging.
|
|
COPY --from=builder /app/scripts/lib/console-log.mjs ./scripts/lib/console-log.mjs
|
|
|
|
# Data directory for database, cookies, logs
|
|
RUN mkdir -p /app/data
|
|
VOLUME ["/app/data"]
|
|
|
|
EXPOSE 3000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
|
|
CMD node -e "fetch('http://localhost:3000/api/health').then(r=>r.ok?process.exit(0):process.exit(1)).catch(()=>process.exit(1))"
|
|
|
|
CMD ["node", "dist/index.js"]
|