2026-07-30 13:18:44 +07:00
|
|
|
# ---- Builder stage ----
|
2026-07-30 12:14:24 +07:00
|
|
|
FROM node:22-slim AS builder
|
|
|
|
|
|
|
|
|
|
WORKDIR /build
|
|
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
RUN npm install -g pnpm@10
|
2026-07-30 12:14:24 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# Build tools for native addons (discordjs/voice may need node-gyp)
|
2026-07-30 12:14:24 +07:00
|
|
|
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
|
|
|
|
python3 make g++ \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# Copy source + manifests
|
|
|
|
|
COPY services/backend/ ./
|
2026-07-30 12:14:24 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
# Install ALL deps (devDeps needed for TypeScript build)
|
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
|
|
|
|
|
|
|
|
|
|
# Build TypeScript
|
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
|
|
|
# Switch to production-only deps (strips devDeps + cleans .pnpm store)
|
|
|
|
|
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 ----
|
|
|
|
|
FROM node:22-alpine
|
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 ./
|
2026-06-08 17:51:29 +07:00
|
|
|
|
2026-07-30 13:18:44 +07:00
|
|
|
USER node
|
2026-06-08 17:51:29 +07:00
|
|
|
EXPOSE 3000
|
|
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
|
2026-07-30 13:18:44 +07:00
|
|
|
CMD node -e "require('http').get('http://localhost:3000/api/health',r=>process.exit(r.statusCode===200?0:1))"
|
2026-06-01 21:44:29 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
CMD ["node", "dist/index.js"]
|