Skip to content

Optimize Docker configuration and Nginx setup for production#706

Open
Yuvraj-025 wants to merge 1 commit intoSimplQ:masterfrom
Yuvraj-025:master
Open

Optimize Docker configuration and Nginx setup for production#706
Yuvraj-025 wants to merge 1 commit intoSimplQ:masterfrom
Yuvraj-025:master

Conversation

@Yuvraj-025
Copy link
Copy Markdown

I have overhauled the frontend Docker and Nginx configurations to adhere to production best practices, address current build inefficiencies, and fix potential routing issues:

  1. Drastically Improved Docker Build Speeds

Added .dockerignore: Included a .dockerignore file to block node_modules/, build/, .git/, and other local artifacts from being copied. This will significantly reduce the Docker context size and fix memory bloat during builds.
Enabled Layer Caching: Reordered the Dockerfile so package.json and package-lock.json are copied and installed (npm ci) before copying the rest of the source code. Now, Docker will cache our heavy NPM install layer during builds, saving massive amounts of time unless dependencies actually change.

  1. Hardened Nginx Setup for Single Page Application (SPA)

Fixed Client-Side Routing: Injected the try_files $uri $uri/ /index.html; directive into nginx.conf. This is crucial for React Router; without it, navigating directly to nested routes (or refreshing them) would throw a 404 Not Found error.
Improved Client-Side Caching: Added cache expires max; directives for all static assets (js, css, png, SVG, etc.) to optimize browser load times on the client side.

  1. Cleanup & Dependability

Mapped Nginx to serve out of its standard safe directory (/usr/share/nginx/html).
Ensured the container properly calls our npm run config && npm run build pipeline explicitly.
These changes make our Docker build pipeline far more efficient and guarantee our routing works seamlessly when the container is deployed.

@Yuvraj-025 Yuvraj-025 requested a review from maaverik as a code owner April 14, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant