68 lines
2.1 KiB
Docker
68 lines
2.1 KiB
Docker
FROM node:22-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install pnpm
|
|
RUN npm install -g pnpm
|
|
|
|
# Create non-root user
|
|
RUN groupadd --system app && useradd --system -g app app
|
|
|
|
# Install build tools for native dependencies (node-crc, @discordjs/opus)
|
|
# and ffmpeg for voice transmit (PCM to OggOpus encoding)
|
|
# This is done early to cache this expensive layer
|
|
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
|
python3 make g++ ffmpeg curl ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Rust via rustup (Debian's rustc/cargo is too old for node-crc)
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
# Copy dependency definition files first for better caching
|
|
COPY pnpm-workspace.yaml .
|
|
COPY pnpm-lock.yaml .
|
|
COPY package.json .
|
|
|
|
# Copy patches (pnpm patchedDependencies)
|
|
COPY patches ./patches
|
|
|
|
# Copy packages (workspace dependencies)
|
|
COPY packages/shared ./packages/shared
|
|
|
|
# Copy Drizzle migrations (relative path used by migrator)
|
|
COPY services/discord-gateway/drizzle ./drizzle
|
|
|
|
# Copy service source (last — changes most often)
|
|
COPY services/discord-gateway ./services/discord-gateway
|
|
|
|
# Install dependencies with build cache
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
|
pnpm install --frozen-lockfile
|
|
|
|
# Build shared workspace dependency first
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
|
pnpm --filter './packages/shared' run build
|
|
|
|
# Build discord gateway
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
|
pnpm --filter './services/discord-gateway' run build
|
|
|
|
# Create recordings directory
|
|
RUN mkdir -p /app/recordings
|
|
|
|
# Own everything by non-root user
|
|
RUN chown -R app:app /app
|
|
|
|
# Switch to non-root user
|
|
USER app
|
|
|
|
# Expose no HTTP port (gateway is internal-only)
|
|
|
|
# Healthcheck — verify PID 1 (node) is still running (no HTTP server in this service)
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
|
CMD sh -c "kill -0 1"
|
|
|
|
# Start discord gateway
|
|
CMD ["node", "services/discord-gateway/dist/index.js"]
|