Run Vite + React in docker with Hot Module Reload

35 Views Asked by At

Currently, I am working on a project with Vite + React and now I want to dockerize it. Actually, I am beginner to Docker. So, I need guidance on how to build the Docker image and run it.

I tried once and it worked, but not as I supposed.

Can anyone help me with following,

  • How to dockerize the React app with Vite?
  • How to run the webapp on local host when developing?
  • Hot Module Reload tool in Vite didn't work for me, how to fix it?

I used following commands in cmd: docker build . and docker run -p 5173:5173 0ac94edb8feb

And here is my Dockerfile:

FROM node:18-alpine

WORKDIR /app

COPY package.json .

RUN npm install

COPY . .

EXPOSE 5173

CMD ["npm", "run", "dev"]

Give me instructions to fix above issue.

0

There are 0 best solutions below