This repository contains a simple guide to create and Dockerize a React app for development. Follow the steps below to get started.
Before you begin, make sure you have the following prerequisites installed on your system:
- Docker
- Node.js and npm
To create a new React app, follow these commands:
npx create-react-app docker-react
cd docker-react
node_modules
build
.dockerignore
Dockerfile
Dockerfile.prod
FROM node:13.12.0-alpine
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm install --silent
RUN npm install react-scripts@5.0.1 -g --silent
COPY . ./
CMD ["npm", "start"]
docker build -t dockerreactimage:dev .
docker run -it -p 3000:3000 dockerreactimage:dev