https://mattermost.com/blog/how-to-deploy-a-react-app-to-kubernetes-using-docker/

https://www.docker.com/resources/kubernetes-and-docker/

install

Dockerfile

Write the Dockerfile

  1. Create Dockerfile at root directory of React app

    1. Set Application Base Image
    2. React runs on Node.js
    3. Create Working Directory
    4. Copy Dependencies files to app dir
    5. Install Dependencies to Docker app dir
    6. Copy all Project Files to Docker app dir
    7. Add Command to Run App inside Docker Container
    # set the base image to build from 
    FROM node:alpine
    
    # set the working directory
    WORKDIR /app
    
    # copy package files
    COPY package.json ./
    COPY package-lock.json ./
    
    # install dependencies
    RUN npm install
    
    # copy everything to /app directory
    COPY ./ ./
    
    # run the app
    CMD ["npm", "start"]
    
  2. Add a .dockerignore file

    1. add files/folders that you don’t want to copy to Docker
    node_modules
    .git
    npm-debug.log
    Dockerfile
    

Run the React App on Docker