A very simple and short guide to dockerize a React app.
Create a new React app
$ npx create-react-app dockerized-react-app
Cd into your project
$ cd dockerized-react-app
Create a file named Dockerfile
FROM node:alpine
WORKDIR '/app'
COPY ./package.json ./
RUN npm install
COPY . .
CMD ["npm", "run", "start"]
Create a docker-compose file docker-compose.yml
version: '3'
services:
app:
container_name: my-dockerized-react-app
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/app'
- '/app/node_modules'
ports:
- 3000:3000
Build your container
$ docker-compose up -d --build
Go to http://localhost:3000/
Top comments (0)