Deploy with a Dockerfile

Deploying with a Dockerfile is the standard way of deploying on Dockhive without the need for proposal.hive files. Users can easily ship a container with just a Dockerfile without requiring any firsthand knowledge of the platform. In the example below, we are going to create a Flask app and wrap it in a container. But before diving into the details, let's first set up our project.

You should have your project structure set up as shown in the screenshot below:

Ensuring that your project is organized correctly from the outset will streamline the process of containerizing your application. Now, let's proceed with creating our Flask app and Dockerfile. Let's add a simple HTML code to the index.html file in the templates directory. See the code below:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello World App On DockHive Network</title>

        body {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;

            .container {
            text-align: center;

            h1 {
            font-size: 3rem;
            color: #333;
    <div class="container">
        <h1>Hello, World!</h1>

Let's render the HTML code in our Flask app and set up

from flask import Flask, render_template
app = Flask(__name__)

def index():
    return render_template('index.html')

if __name__ == '__main__':'', port=8000, debug=True)

Note that you need to make sure your application is running on This will make it accessible to the internet once distributed to the nodes.

Setting up your Dockerfile

I assume you have background knowledge of containerisation and python , you can checkout this to learn more about Python , Flask and Docker

Add the following Dockerfile configuration code to your Dockerfile in your root project directory.

# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Set the working directory to /app

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

# Install any needed packages specified in requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt

#make sure you expose your actual  app port 

# Run when the container launches
CMD ["python3", ""]

Build and test your container before deploying it to the network. Remember, if the container works on your machine, it will work in production.

Add Git and Push , Deploy

If your build and test are successful and it works, congratulations! Now let's deploy it on the network. First, push your code to the repository of your choice using GitHub. Then, go to your DockHive dashboard and create a project.

To connect to Git, click on GitHub. Note that GitLab is not available on the testnet.

Your screen will be populated with your GitHub repositories. Make sure you allow every permission requested during onboarding to access all your repos, as seen in the screenshot below. Search for the repo you want to deploy.

Once you have selected the repository you want to deploy, you will see a list of branches attached to the repository, as shown in the screenshot below.

For the Flask app we want to deploy, we only have one branch, which is the main branch. Click "Save and Deploy" on the bottom right side corner of the screen. After a successful deploy you should the see your logs as seen below

On the top right side of the screen, click on "Continue to Project". You will see a screen as seen below. Click on "Visit Site".

Congratulations! We have deployed our Flask app on the Dockhive network. View the site below.

Last updated