How to Deploy a flask app on dockhive
Documentation: Deploying a Flask App on DockHive
This comprehensive guide walks you through the process of deploying a Flask web application on DockHive's decentralized cloud infrastructure. By following these steps, you can deploy your Flask app and access it via a URL like projectname.dockhive.io
.
1. Prepare Your Flask App
Ensure your Flask application is structured correctly and contains the necessary files, including app.py
.
Example Flask App:
# app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, welcome to my Flask app on DockHive!'
if __name__ == '__main__':
app.run(debug=True)
2. Create a Dockerfile
Create a Dockerfile
in the root directory of your Flask application.
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 Flask
RUN pip install --no-cache-dir Flask
# Make port 5000 available to the world outside this container
EXPOSE 5000
# Run app.py when the container launches
CMD ["python", "app.py"]
3. Create a Proposal File
Create a proposal.hive
file in the root directory of your project.
Proposal File:
containers:
- name: flask_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 Flask 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 Flask 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 Flask app, such as projectname.dockhive.io
.
Conclusion
Congratulations! Your Flask 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