mirror of
https://github.com/taylanbakircioglu/haproxy-openmanager.git
synced 2026-09-19 17:15:12 +00:00
281e23ea27
This is a comprehensive update that adds SSL certificate differentiation for frontend (HAProxy bind) and server (backend verification) use cases. FEATURES: - SSL certificates can be marked as 'frontend' or 'server' usage type - Frontend SSL: Private key REQUIRED (for HAProxy bind ssl crt) - Server SSL: Private key OPTIONAL (CA cert only for backend verification) - UI dropdown for usage type selection - Dynamic form validation based on usage type - Filtering: Frontends see only Frontend SSL, Backends see only Server SSL DATABASE: - Added usage_type column to ssl_certificates (default: 'frontend') - Made private_key_content nullable for server SSL support - Migration automatically runs on pod restart BACKEND: - Pydantic v2 compatibility (@field_validator, @model_validator) - SSL router: usage_type filtering support - Agent endpoint: usage_type field included - Improved migration robustness with better error handling - Fixed duplicate ensure_agents_table() function - Fixed JSONB permissions insert with json.dumps() - Fixed ON CONFLICT constraints with explicit checks FRONTEND: - SSL Management: Usage Type dropdown with visual feedback - Frontend Management: Filters only Frontend SSL certificates - Backend Servers: Filters only Server SSL certificates - Dynamic private key validation (required for Frontend, optional for Server) - Improved form UX with color-coded hints AGENT SCRIPTS (Linux & macOS): - Support for Server SSL without private key - Conditional PEM file creation (cert+key vs cert-only) - usage_type awareness in SSL deployment - Backward compatible with existing Frontend SSL certificates DOCKER: - Increased npm timeout for slow networks (300s → 600s) - Increased fetch-retries (5 → 10) - Reduced maxsockets for stability (3 → 1) All changes are backward compatible. Existing SSL certificates default to 'frontend' type and continue working unchanged. Tested with: HAProxy 2.8+, PostgreSQL 15, React 18
68 lines
2.2 KiB
Docker
68 lines
2.2 KiB
Docker
# Multi-stage build for production
|
|
# Use Alpine for smaller image and better resource management
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Reduce npm file descriptor usage and disable unnecessary network/audit work
|
|
ENV npm_config_fund=false \
|
|
npm_config_audit=false \
|
|
npm_config_progress=false
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies with aggressive network timeout optimization
|
|
RUN npm cache clean --force \
|
|
&& npm config set maxsockets 1 \
|
|
&& npm config set fetch-retries 10 \
|
|
&& npm config set fetch-retry-mintimeout 30000 \
|
|
&& npm config set fetch-retry-maxtimeout 300000 \
|
|
&& npm config set fetch-timeout 600000 \
|
|
&& npm config set registry https://registry.npmjs.org/ \
|
|
&& npm install --no-audit --no-fund --progress=false --legacy-peer-deps --timeout=600000 \
|
|
&& npm cache clean --force
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Run unit tests during build (fails build if tests fail)
|
|
# Temporarily disabled due to Babel configuration issues
|
|
# RUN npm test -- --coverage --watchAll=false --testTimeout=30000 || \
|
|
# (echo "❌ FRONTEND TESTS FAILED - Build aborted" && exit 1)
|
|
|
|
# Build production bundle using the legacy OpenSSL provider for Node 18+ compatibility
|
|
RUN NODE_OPTIONS=--openssl-legacy-provider npm run build
|
|
|
|
# Production stage
|
|
FROM node:18-alpine AS production
|
|
|
|
WORKDIR /app
|
|
|
|
# Keep npm quiet and reduce file operations in runtime image too
|
|
ENV npm_config_fund=false npm_config_audit=false npm_config_progress=false
|
|
|
|
# Install serve to serve static files with aggressive timeout optimization
|
|
RUN npm config set fetch-timeout 600000 \
|
|
&& npm config set fetch-retries 10 \
|
|
&& npm config set maxsockets 1 \
|
|
&& npm install -g serve --no-fund --no-audit --progress=false --timeout=600000
|
|
|
|
# Create non-root user for OpenShift compatibility (Alpine-based)
|
|
RUN addgroup -g 1001 nodejs && \
|
|
adduser -D -u 1001 -G nodejs -h /home/reactjs reactjs
|
|
|
|
# Copy built application from builder stage
|
|
COPY --from=builder /app/build ./build
|
|
|
|
# Change ownership to non-root user
|
|
RUN chown -R reactjs:nodejs /app
|
|
|
|
# Switch to non-root user
|
|
USER reactjs
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Start production server
|
|
CMD ["serve", "-s", "build", "-l", "3000"] |