mirror of
https://github.com/taylanbakircioglu/flowfish.git
synced 2026-09-11 21:38:54 +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.
72 lines
2.1 KiB
Docker
72 lines
2.1 KiB
Docker
# Flowfish Frontend Dockerfile
|
|
# Build context should be workspace root
|
|
|
|
# Build stage
|
|
FROM node:18-alpine AS builder
|
|
|
|
# Cache bust - increment to force fresh build
|
|
ARG CACHE_BUST=20260130v2
|
|
RUN echo "Build: $CACHE_BUST"
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files from frontend directory
|
|
COPY frontend/package*.json ./
|
|
|
|
# Fix EMFILE "too many open files" - all in one layer with env vars
|
|
ENV npm_config_cache=/tmp/npm-cache
|
|
ENV npm_config_maxsockets=1
|
|
ENV npm_config_fetch_retries=3
|
|
ENV npm_config_loglevel=warn
|
|
|
|
# Install dependencies with aggressive cleanup
|
|
RUN rm -rf /root/.npm /tmp/* node_modules && \
|
|
mkdir -p /tmp/npm-cache && \
|
|
npm install --legacy-peer-deps --no-audit --no-fund --prefer-offline 2>&1 || \
|
|
(echo "Retry with clean cache..." && rm -rf /tmp/npm-cache && mkdir -p /tmp/npm-cache && npm install --legacy-peer-deps --no-audit --no-fund)
|
|
|
|
# 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
|
|
|
|
# Build production bundle with increased memory
|
|
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
# 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 website
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
# Copy built app
|
|
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
|
|
|
|
# OpenShift compatibility: Set permissions for arbitrary UID
|
|
RUN chown -R nginx:0 /usr/share/nginx/html && \
|
|
chmod -R g=u /usr/share/nginx/html && \
|
|
chown -R nginx:0 /var/cache/nginx && \
|
|
chmod -R g=u /var/cache/nginx && \
|
|
chown -R nginx:0 /var/run && \
|
|
chmod -R g=u /var/run
|
|
|
|
# Switch to non-root user
|
|
USER nginx
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:3000/ || exit 1
|
|
|
|
# Start nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|