How to deploy react js app on dockhive

Documentation: Deploying a React App on DockHive

This comprehensive guide walks you through the process of deploying a React web application on DockHive's decentralized cloud infrastructure. By following these steps, you can deploy your React app and access it via a URL like projectname.dockhive.io.

1. Prepare Your React App

Ensure your React application is structured correctly and contains the necessary files, including index.html, App.js, and other components.

2. Create a Dockerfile

Create a Dockerfile in the root directory of your React application.

Dockerfile:

# Use an official Node.js runtime as a parent image
FROM node:14

# Set the working directory to /app
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install app dependencies
RUN npm install

# Copy the current directory contents into the container at /app
COPY . .

# Build the React app for production
RUN npm run build

# Install serve to run the production build
RUN npm install -g serve

# Expose port 3000 to the outside world
EXPOSE 3000

# Run serve to serve the React app
CMD ["serve", "-s", "build"]

3. Create a Proposal File

Create a proposal.hive file in the root directory of your project.

Proposal File:

containers:
  - name: react_app_container
    location: /path/to/Dockerfile
    profile: null
    resources:
      cpu: 2
      memory: 4GB
    environment: null
    scaling:
      auto_scale: true

Replace /path/to/Dockerfile with the actual path to your Dockerfile.

4. Connect GitHub Account to DockHive

Log in to your DockHive account and navigate to the settings page. Connect your GitHub account to DockHive and specify the branch you want to deploy.

5. Push Changes to GitHub

Push your React application code, along with the Dockerfile and proposal.hive files, to the GitHub branch connected to DockHive.

6. Deployment Process

DockHive will automatically detect the changes in your GitHub repository and initiate the deployment process based on the proposal file. Once approved, your React app will be deployed on DockHive's decentralized cloud infrastructure.

7. Access Your Deployed App

Once the deployment process is complete, DockHive will provide you with a unique URL to access your deployed React app, such as projectname.dockhive.io.

Conclusion

Congratulations! Your React app is now deployed and accessible on DockHive's decentralized cloud infrastructure. By connecting your GitHub account and pushing your code changes, you can effortlessly deploy and manage your applications on the network.

Last updated