mirror of
https://github.com/taylanbakircioglu/flowfish.git
synced 2026-09-12 05:48:55 +00:00
d5f9b1833d
The frontend image was flagged on nginx 1.31.0 because the Dockerfiles used the floating nginx:alpine (mainline) tag. No rewrite directives exist in any nginx config, so the named-capture mitigation does not apply; the remediation is the version update. Pin every nginx reference to the patched 1.31.1-alpine release: - frontend/Dockerfile, Dockerfile.production, Dockerfile.simple - deployment/local-test/14-nginx-proxy.yaml (was nginx:alpine) - deployment/local-test/l7-sample-apps.yaml (was nginx:1.25-alpine) Validated with `nginx -t` on 1.31.1 for all configs.
81 lines
2.2 KiB
Docker
81 lines
2.2 KiB
Docker
# Flowfish Frontend - Production Build (Fixed)
|
|
# Multi-stage build for optimized React app
|
|
|
|
# Build stage
|
|
FROM node:18-alpine AS builder
|
|
|
|
# Cache bust argument - change this to force rebuild
|
|
ARG CACHE_BUST=1
|
|
RUN echo "Cache bust: $CACHE_BUST"
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files (build context is workspace root)
|
|
COPY frontend/package*.json ./
|
|
|
|
# Install ALL dependencies (including dev) for build
|
|
# Use legacy peer deps to avoid conflicts
|
|
RUN npm install --legacy-peer-deps
|
|
|
|
# Force cache invalidation for source code copy
|
|
# This ARG changes on each build, invalidating all subsequent layers
|
|
ARG CACHE_BUST
|
|
RUN echo "Source cache bust: $CACHE_BUST"
|
|
|
|
# Copy source code from frontend directory
|
|
COPY frontend/ .
|
|
|
|
# Copy root version.json so build scripts can read it via require('../version.json')
|
|
COPY version.json /version.json
|
|
|
|
# Set production environment
|
|
ENV NODE_ENV=production
|
|
ENV GENERATE_SOURCEMAP=false
|
|
ENV DISABLE_ESLINT_PLUGIN=true
|
|
|
|
# CRITICAL: This env var is included in the bundle and forces unique hash
|
|
# REACT_APP_* variables are embedded by Create React App
|
|
ARG CACHE_BUST
|
|
ENV REACT_APP_BUILD_TIMESTAMP=$CACHE_BUST
|
|
|
|
# Clear any build cache
|
|
RUN rm -rf node_modules/.cache
|
|
|
|
# Build the app
|
|
RUN npm run build
|
|
|
|
# Production stage with Nginx
|
|
# Pinned to a patched nginx release (>= 1.31.1) to remediate the "poolslip"
|
|
# advisory; the floating nginx:alpine tag previously shipped vulnerable 1.31.0.
|
|
FROM nginx:1.31.1-alpine AS production
|
|
|
|
# Remove default nginx config
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
# Copy built app from builder
|
|
COPY --from=builder /app/build /usr/share/nginx/html
|
|
|
|
# Copy nginx configuration from frontend directory
|
|
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 101 -S nginx 2>/dev/null || true && \
|
|
adduser -S -D -H -u 101 -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx 2>/dev/null || true
|
|
|
|
# Change ownership
|
|
RUN chown -R nginx:nginx /usr/share/nginx/html /var/cache/nginx /var/log/nginx /etc/nginx 2>/dev/null || true
|
|
|
|
# Switch to non-root user
|
|
USER nginx
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD wget -q --spider http://localhost:3000/ || exit 1
|
|
|
|
# Start nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|
|
|