# 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:

<figure><img src="/files/Ul1A0N31574N0AdRfGUm" alt=""><figcaption><p>Project Structure Screen</p></figcaption></figure>

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:

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

    <style>
        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;
            }
    </style>
</head>
<body>
    <div class="container">
        <h1>Hello, World!</h1>
      </div>
</body>
</html>
```

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

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


@app.route('/')
def index():
    return render_template('index.html')

if __name__ == '__main__':
  app.run(host='0.0.0.0', port=8000, debug=True)
 
```

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

## Setting up your Dockerfile&#x20;

I assume you have background knowledge of containerisation and python , you can checkout this to learn more about [Python](https://python.org)  , [Flask](https://flask.palletsprojects.com/en/3.0.x/) and [Docker](https://docs.docker.com/)

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

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

# Set the working directory to /app
WORKDIR /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 
EXPOSE 8000

# Run app.py when the container launches
CMD ["python3", "app.py"]
```

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](https://testnet.dockhive.io) dashboard and create a project.

<figure><img src="/files/c0V7kEo73rNNTWMbTqVD" alt=""><figcaption><p>click on create project</p></figcaption></figure>

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

<figure><img src="/files/qxI4xZJaw4DB8xzAtjft" alt=""><figcaption><p>click on github</p></figcaption></figure>

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.

<figure><img src="/files/knCCICj7IYPSKXPOxf73" alt=""><figcaption><p>search for the repo you want to deploy and select it</p></figcaption></figure>

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.

<figure><img src="/files/jDGWlpCHElAfSzuO58d1" alt=""><figcaption><p>selected branch is main</p></figcaption></figure>

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 <br>

<figure><img src="/files/EwEj9jZLUsGbNkQyxZI6" alt=""><figcaption><p>successful deploy log</p></figcaption></figure>

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".

<figure><img src="/files/LwjEJGIjn9APs5tT1WBQ" alt=""><figcaption><p>click on visit site</p></figcaption></figure>

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

<https://awesome-rocket-yfd8.dockhive.app/><br>

<figure><img src="/files/CHW6EuLn67grxa9yGgrD" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dockhive.io/app-deployment/deploy-with-a-dockerfile.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
