Files
GMW/infra/docker/Dockerfile.discord-gateway
T

53 lines
1.6 KiB
Docker
Raw Normal View History

# ---- Builder stage ----
FROM node:22-slim AS builder
WORKDIR /build
RUN npm install -g pnpm@10
# Build tools + Rust (required by napi-rs native addons)
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
python3 make g++ curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Rust toolchain
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
ENV PATH="/root/.cargo/bin:${PATH}"
COPY services/discord-gateway/ ./
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
pnpm install --no-frozen-lockfile
RUN ./node_modules/.bin/tsc
# 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"
# Switch to production-only deps
RUN rm -rf node_modules && pnpm install --prod --no-frozen-lockfile
# ---- Runtime stage ----
FROM node:22-slim
# 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/*
WORKDIR /app
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
RUN mkdir -p /app/recordings
USER node
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD node -e "process.exit(0)"
CMD ["node", "dist/index.js"]