-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Update Dockerfile to use correct npm script for frontend service #1020
Fix: Update Dockerfile to use correct npm script for frontend service #1020
Conversation
This commit addresses an issue in the frontend Dockerfile where the `CMD` directive attempted to execute `npm run local`, a script that doesn't exist in `package.json`. This discrepancy caused the Docker container for the frontend to fail to start, hindering the setup process for developers and contributors working with Docker. Changes made: - Updated the `CMD` in the Dockerfile to use `npm run dev -- --host 0.0.0.0`, aligning it with the available scripts defined in `package.json` and ensuring the development server listens on all network interfaces within the Docker container. This adjustment facilitates access to the frontend service from the host machine or other Docker containers. Verification: - Rebuilt the Docker image for the frontend and verified that the container starts successfully and is accessible on `http://localhost:3000`. - Ensured that the frontend application functions as expected when accessed through the browser. This fix streamlines the developer experience by ensuring the Docker setup process is smooth and aligns with the project's current frontend tooling configuration.
This reverts commit 681f175.
This commit addresses an issue in the frontend Dockerfile where the `CMD` directive attempted to execute `npm run local`, a script that doesn't exist in `package.json`. This discrepancy caused the Docker container for the frontend to fail to start, hindering the setup process for developers and contributors working with Docker. Changes made: - Updated the `CMD` in the Dockerfile to use `npm run dev -- --host 0.0.0.0`, aligning it with the available scripts defined in `package.json` and ensuring the development server listens on all network interfaces within the Docker container. This adjustment facilitates access to the frontend service from the host machine or other Docker containers. Verification: - Rebuilt the Docker image for the frontend and verified that the container starts successfully and is accessible on `http://localhost:3000`. - Ensured that the frontend application functions as expected when accessed through the browser. This fix streamlines the developer experience by ensuring the Docker setup process is smooth and aligns with the project's current frontend tooling configuration.
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is not :
CMD ["npm", "run", "dev"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @salahlalami,
Thanks for the review! The "--", "--host", "0.0.0.0" part of the command is there to ensure that the development server listens on all network interfaces inside the Docker container. Without it, the server would only be accessible from within the container itself and wouldn't respond to requests from the host machine or other containers. This change ensures that developers can access the frontend service from their local machine when the Docker container is running.
If our Docker setup or Vite's default configuration ensures the server listens on all interfaces without explicitly setting the host, we can certainly simplify the command to just "npm", "run", "dev". I included it for compatibility and accessibility, but I'm open to updating this per your guidance.
@Jeetpal1 Thank you |
Fix: Update Dockerfile to use correct npm script for frontend service
Description
This pull request addresses the issue found in the frontend Dockerfile where the command
npm run local
was specified. Since there is nolocal
script inpackage.json
, this command would cause the Docker container to fail to start. I have updated the Dockerfile to execute thedev
script instead, which aligns with the existing scripts defined inpackage.json
and ensures that the Docker container for the frontend can start and run without issues.Related Issues
Steps to Test
docker-compose build
to rebuild the frontend service with the updated Dockerfile.docker-compose up
.http://localhost:3000
to ensure that the frontend service is running and accessible.Screenshots (if applicable)
N/A (The change is in the configuration file and does not affect the visual aspect of the application.)
Checklist
npm
command.CMD
instruction).Fix incorrect npm script in Dockerfile for frontend
).