mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:41:09 +02:00
Implement custom NestJS API Gateway for mana-search, mana-stt, and mana-tts: - API Key management with CRUD operations and key regeneration - Redis-based sliding window rate limiting - Credit-based billing with tier support (free, pro, enterprise) - Usage tracking with daily aggregates - Proxy services to backend microservices - Prometheus metrics endpoint - JWT auth for management API, API key auth for public API Database schema uses separate `api_gateway` schema in shared manacore DB.
32 lines
796 B
Docker
32 lines
796 B
Docker
FROM node:20-alpine AS base
|
|
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
|
WORKDIR /app
|
|
|
|
# Install dependencies
|
|
FROM base AS deps
|
|
COPY package.json pnpm-lock.yaml* ./
|
|
RUN pnpm install --frozen-lockfile --prod=false
|
|
|
|
# Build the application
|
|
FROM base AS builder
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN pnpm build
|
|
|
|
# Production image
|
|
FROM base AS runner
|
|
ENV NODE_ENV=production
|
|
|
|
# Create non-root user
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nestjs
|
|
USER nestjs
|
|
|
|
# Copy built application
|
|
COPY --from=builder --chown=nestjs:nodejs /app/dist ./dist
|
|
COPY --from=builder --chown=nestjs:nodejs /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=nestjs:nodejs /app/package.json ./
|
|
|
|
EXPOSE 3030
|
|
|
|
CMD ["node", "dist/main.js"]
|