Optimize Docker configuration and Nginx setup for production#706
Open
Yuvraj-025 wants to merge 1 commit intoSimplQ:masterfrom
Open
Optimize Docker configuration and Nginx setup for production#706Yuvraj-025 wants to merge 1 commit intoSimplQ:masterfrom
Yuvraj-025 wants to merge 1 commit intoSimplQ:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have overhauled the frontend Docker and Nginx configurations to adhere to production best practices, address current build inefficiencies, and fix potential routing issues:
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.
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.
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.