I want to develop react application but i don’t have node and npm(Unable to install because i’ve restriction). I’ve decided to use docker. But whenever i did changes it’s not reflecting.
This is my Dockerfile
<code># Use an official Node runtime as a parent image
FROM node:14
# Set the working directory in the container
WORKDIR /app
# Install `create-react-app` globally
RUN npm install -g create-react-app
# Create a new React app
RUN create-react-app my-app
# Change working directory to the new React app
WORKDIR /app/my-app
# Install serve to serve the app
RUN npm install -g serve
#RUN npm install npm-watch
RUN npm install --save-dev nodemon
# Copy package.json and package-lock.json to the working directory
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Build the React app
RUN npm run build
# Serve the React app
CMD ["serve", "-s", "build"]
# Expose port 3000 to the outside world
EXPOSE 3000
</code>
<code># Use an official Node runtime as a parent image
FROM node:14
# Set the working directory in the container
WORKDIR /app
# Install `create-react-app` globally
RUN npm install -g create-react-app
# Create a new React app
RUN create-react-app my-app
# Change working directory to the new React app
WORKDIR /app/my-app
# Install serve to serve the app
RUN npm install -g serve
#RUN npm install npm-watch
RUN npm install --save-dev nodemon
# Copy package.json and package-lock.json to the working directory
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Build the React app
RUN npm run build
# Serve the React app
CMD ["serve", "-s", "build"]
# Expose port 3000 to the outside world
EXPOSE 3000
</code>
# Use an official Node runtime as a parent image
FROM node:14
# Set the working directory in the container
WORKDIR /app
# Install `create-react-app` globally
RUN npm install -g create-react-app
# Create a new React app
RUN create-react-app my-app
# Change working directory to the new React app
WORKDIR /app/my-app
# Install serve to serve the app
RUN npm install -g serve
#RUN npm install npm-watch
RUN npm install --save-dev nodemon
# Copy package.json and package-lock.json to the working directory
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Build the React app
RUN npm run build
# Serve the React app
CMD ["serve", "-s", "build"]
# Expose port 3000 to the outside world
EXPOSE 3000
docker-compose.yaml
<code>version: '3.8'
services:
react-app:
build: .
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
- /app
environment:
- CHOKIDAR_USEPOLLING=true
command: npm start
</code>
<code>version: '3.8'
services:
react-app:
build: .
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
- /app
environment:
- CHOKIDAR_USEPOLLING=true
command: npm start
</code>
version: '3.8'
services:
react-app:
build: .
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
- /app
environment:
- CHOKIDAR_USEPOLLING=true
command: npm start
I’m modifying Docker’s App.js, but the changes aren’t showing up in the browser.
Whenever i did the changes inside docker it should reflect it on the browser.