Files
GMW/infra/docker/Dockerfile.discord-gateway
T
MythEclipse 6f4053c1cc fix(docker): add build tools for native dependencies in discord-gateway
Install python3, make, g++, rust, and cargo in Alpine image to resolve:
- node-crc native build failure (requires cargo)
- @discordjs/opus native build issues (requires build tools)

This fixes the GitHub Actions build failure in the discord-gateway service.
2026-06-08 20:16:47 +07:00

60 lines
1.5 KiB
Docker

FROM node:22-alpine
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Create non-root user
RUN addgroup -S app && adduser -S -G app app
# Copy workspace files
COPY pnpm-workspace.yaml .
COPY pnpm-lock.yaml .
COPY package.json .
# Copy vendor packages (workspace dependencies)
COPY vendor/discord.js-selfbot-v13 ./vendor/discord.js-selfbot-v13
# Copy packages (workspace dependencies)
COPY packages/shared ./packages/shared
# Copy patches (pnpm patchedDependencies)
COPY patches ./patches
# Copy service
COPY services/discord-gateway ./services/discord-gateway
# Copy Drizzle migrations (relative path used by migrator)
COPY services/discord-gateway/drizzle ./drizzle
# Install build tools for native dependencies (node-crc, @discordjs/opus)
RUN apk add --no-cache python3 make g++ rust cargo
# Install dependencies
RUN pnpm install --frozen-lockfile
# Build shared workspace dependency first
RUN pnpm --filter './packages/shared' run build
# Build discord gateway
RUN 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"]