Deploy with a Dockerfile
Last updated
Last updated
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:
Let's render the HTML code in our Flask app and set up app.py.
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.
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.
Build and test your container before deploying it to the network. Remember, if the container works on your machine, it will work in production.
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.
https://awesome-rocket-yfd8.dockhive.app/