- Create API gateway service with Express.js - Implement sliding window rate limiting via Redis - Add API key management with tiered access (free/developer/enterprise) - Track usage analytics per key and globally - Add RPC proxy to blockchain nodes - Configure Docker Compose with api-gateway and redis services - Free tier: 100 req/min, Developer: 1000 req/min, Enterprise: unlimited
35 lines
529 B
Docker
35 lines
529 B
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies
|
|
COPY package.json ./
|
|
RUN npm install
|
|
|
|
# Build TypeScript
|
|
COPY tsconfig.json ./
|
|
COPY src ./src
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json ./
|
|
|
|
# Install production dependencies only
|
|
RUN npm install --production
|
|
|
|
# Copy built files
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
# Set environment variables
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3100
|
|
|
|
EXPOSE 3100
|
|
|
|
CMD ["node", "dist/index.js"]
|