underrate commited on
Commit
6182ef3
·
verified ·
1 Parent(s): d53e5b4

Upload 26 files

Browse files
Files changed (2) hide show
  1. Dockerfile +6 -3
  2. src/middleware/rate-limiter.ts +0 -7
Dockerfile CHANGED
@@ -22,16 +22,19 @@ COPY . .
22
  RUN npm run build
23
 
24
  # Production stage
25
- FROM node:20-alpine AS runner
26
 
27
  WORKDIR /app
28
 
29
  # Set to production
30
  ENV NODE_ENV=production
31
 
 
 
 
32
  # Create non-root user for security
33
- RUN addgroup --system --gid 1001 nodejs
34
- RUN adduser --system --uid 1001 appuser
35
 
36
  # Copy necessary files from builder
37
  COPY --from=builder /app/dist ./dist
 
22
  RUN npm run build
23
 
24
  # Production stage
25
+ FROM node:20-bookworm-slim AS runner
26
 
27
  WORKDIR /app
28
 
29
  # Set to production
30
  ENV NODE_ENV=production
31
 
32
+ # Install OpenSSL for Prisma
33
+ RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
34
+
35
  # Create non-root user for security
36
+ RUN groupadd --system --gid 1001 nodejs
37
+ RUN useradd --system --uid 1001 --gid nodejs appuser
38
 
39
  # Copy necessary files from builder
40
  COPY --from=builder /app/dist ./dist
src/middleware/rate-limiter.ts CHANGED
@@ -9,10 +9,6 @@ export const publicFormLimiter = rateLimit({
9
  max: maxRequests, // Default: limit each IP to 5 requests per windowMs
10
  standardHeaders: true,
11
  legacyHeaders: false,
12
- keyGenerator: (req) => {
13
- // Fallback to connection.remoteAddress if IP is missing
14
- return req.ip || req.connection.remoteAddress || 'unknown';
15
- },
16
  message: {
17
  error: "Too many requests",
18
  details: "Please try again later after 15 minutes",
@@ -25,9 +21,6 @@ export const authLimiter = rateLimit({
25
  max: 10, // Limit each IP to 10 login attempts per window
26
  standardHeaders: true,
27
  legacyHeaders: false,
28
- keyGenerator: (req) => {
29
- return req.ip || req.connection.remoteAddress || 'unknown';
30
- },
31
  message: {
32
  error: "Too many login attempts",
33
  details: "Account temporarily locked for 15 minutes due to too many failed attempts"
 
9
  max: maxRequests, // Default: limit each IP to 5 requests per windowMs
10
  standardHeaders: true,
11
  legacyHeaders: false,
 
 
 
 
12
  message: {
13
  error: "Too many requests",
14
  details: "Please try again later after 15 minutes",
 
21
  max: 10, // Limit each IP to 10 login attempts per window
22
  standardHeaders: true,
23
  legacyHeaders: false,
 
 
 
24
  message: {
25
  error: "Too many login attempts",
26
  details: "Account temporarily locked for 15 minutes due to too many failed attempts"