2026-07-30 13:18:44 +07:00
|
|
|
# ---- Builder stage ----
|
2026-07-27 21:54:31 +07:00
|
|
|
FROM node:22-slim AS builder
|
|
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
WORKDIR /build
|
2026-07-27 21:54:31 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
RUN npm install -g pnpm@10
|
2026-07-27 21:54:31 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# Build tools + Rust (required by napi-rs native addons)
|
2026-07-27 21:54:31 +07:00
|
|
|
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
|
|
|
|
python3 make g++ curl ca-certificates \
|
2026-07-28 15:47:23 +07:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2026-07-27 21:54:31 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# Install Rust toolchain
|
2026-07-30 12:14:24 +07:00
|
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
|
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
COPY services/discord-gateway/ ./
|
2026-07-30 12:14:24 +07:00
|
|
|
|
|
|
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
|
|
|
|
pnpm install --no-frozen-lockfile
|
|
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
RUN ./node_modules/.bin/tsc
|
2026-07-30 12:14:24 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# Strip debug symbols from native addons
|
|
|
|
|
RUN find node_modules -name '*.node' -exec strip -s {} \; 2>/dev/null; \
|
|
|
|
|
find node_modules -name '*.so' -exec strip -s {} \; 2>/dev/null; \
|
|
|
|
|
echo "Stripped native binaries"
|
2026-07-30 12:14:24 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# Switch to production-only deps
|
|
|
|
|
RUN rm -rf node_modules && pnpm install --prod --no-frozen-lockfile
|
2026-07-30 12:14:24 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# ---- Runtime stage ----
|
2026-07-02 04:07:18 +07:00
|
|
|
FROM node:22-slim
|
2026-06-01 21:44:29 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# Install ffmpeg with minimal dependencies
|
|
|
|
|
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
|
|
|
|
ffmpeg ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2026-06-01 21:44:29 +07:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
COPY --from=builder --chown=node:node /build/dist ./dist
|
|
|
|
|
COPY --from=builder --chown=node:node /build/node_modules ./node_modules
|
|
|
|
|
COPY --from=builder --chown=node:node /build/package.json ./
|
|
|
|
|
COPY --from=builder --chown=node:node /build/drizzle ./drizzle
|
2026-07-02 04:07:18 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
RUN mkdir -p /app/recordings
|
2026-07-27 21:54:31 +07:00
|
|
|
USER node
|
2026-06-01 21:44:29 +07:00
|
|
|
|
2026-06-08 17:51:29 +07:00
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
2026-07-30 13:18:44 +07:00
|
|
|
CMD node -e "process.exit(0)"
|
2026-06-08 17:51:29 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
CMD ["node", "dist/index.js"]
|