How to deploy a node js app on dockhive

Documentation: Deploying a Node.js App on DockHive

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

1. Prepare Your Node.js App

Ensure your Node.js application is structured correctly and contains the necessary files, including server.js.

Example Node.js App:

// server.js

const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello, welcome to my Node.js app on DockHive!');
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

2. Create a Dockerfile

Create a Dockerfile in the root directory of your Node.js 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 . .

# Make port 3000 available to the world outside this container
EXPOSE 3000

# Run server.js when the container launches
CMD ["node", "server.js"]

3. Create a Proposal File

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

Proposal File:

containers:
  - name: node_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 Node.js 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 Node.js 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 Node.js app, such as projectname.dockhive.io.

Conclusion

Congratulations! Your Node.js 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