"Day-24-Building a Python Flask Calculator App with Docker Compose and Pipeline"

"Day-24-Building a Python Flask Calculator App with Docker Compose and Pipeline"

Introduction:

GitHub - helloflask/calculator: A Calculator made by Flask and JavaScript.

In this blog post, we will be building a Python Flask calculator app using a Docker Compose file and a pipeline. Flask is a popular web framework in Python, and Docker Compose is a tool for defining and running multi-container Docker applications. We'll also be using a pipeline to automate the building, testing, and deployment of our app.

Requirements

Before we get started, make sure you have the following tools installed:

  • Docker

  • Docker Compose

  • Python 3.x

  • pip

  • Git

  • A CI/CD pipeline tool such as Jenkins, GitLab CI/CD, or CircleCI

PART-1

Download Learning Free PNG photo images and clipart | FreePNGImg

step-1 Create a docker file and nginx block

Step-2 Create a pipeline to run it.

Step-3 Put ip address on web browser and test it

Part-2

Step-1 Create a Docker-composed file

version: '3'

services:
  calculator:
    image: ubuntu
    container_name: cal
    volumes:
      - ./block:/etc/nginx/sites-available/block
    ports:
      - "8000:80"
    command: bash -c "apt-get update && apt-get install -y nginx python3-venv git && rm /etc/nginx/sites-available/default && rm /etc/nginx/sites-enabled/default && git clone https://github.com/abhijeetpoonia/calculator.git /etc/calculator && cd /etc/calculator && python3 -m venv env && . env/bin/activate && pip install Flask==2.2.3 Jinja2==3.1.2 Werkzeug==2.2.3 gunicorn==19.5.0 gevent && ln -s /etc/nginx/sites-available/block /etc/nginx/sites-enabled/ && gunicorn --bind 0.0.0.0:80 app:app"

Step-2 Create a nginx Block :

server {
    listen 80;
    server_name 3.26.183.63;

    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Create a pipeline to run the docker-compose file :