Skip to content

nogibjj/Mobasserul_Haque_MiniProject12

Repository files navigation

Build and Push Docker Image

Dockerized Application

Project Overview

This project demonstrates a simple Python Flask application containerized using Docker. The application calculates the user's age based on their Date of Birth (DOB). The project incorporates CI/CD to automate building and pushing the Docker image to Docker Hub.


Features

  • Flask Web Application: A web application that calculates age from the provided Date of Birth.
  • Dockerized Deployment: The application is containerized for seamless deployment across environments.
  • Makefile Automation: Simplifies Docker commands for building, running, and pushing the container.
  • CI/CD Integration: Automates the Docker build and push process using GitHub Actions.

Directory Structure

├── .github/
│   └── workflows/
│       └── cicd.yml
├── .coverage
├── .gitignore
├── app.py
├── Dockerfile
├── Makefile
├── README.md
├── requirements.txt

Setup Instructions

  1. Clone the Repository
git clone https://github.com/nogibjj/Mobasserul_Haque_MiniProject12.git
cd Mobasserul_Haque_MiniProject12
  1. Build the Docker Image

Build the Docker image using the Makefile:

make build
  1. Run the Docker Container
make run

Access the application in your browser at http://localhost:5000.

  1. Push the Docker Image to Docker Hub

Authenticate with Docker Hub and push the image:

make push

Flask Application Details

Endpoints

  • Home Page (/): Displays a form for users to enter their Date of Birth. app_img1

  • Calculate Age (/calculate_age): Processes the DOB input and calculates the user's age. app_img2


CI/CD Integration

This project uses GitHub Actions to automate Docker image builds and deployments. The workflow (.github/workflows/cicd.yml) performs the following steps:

  1. Checks out the repository
  2. Logs into Docker Hub using repository secrets
  3. Builds the Docker image
  4. Pushes the image to Docker Hub

Deployment to Docker Hub

Manually

  1. Log in to Docker Hub:
	docker login -u ${DOCKER_ID_USER}

DockerHub_Repo_Img1

  1. Tag the Docker Image:
docker tag dockerized_app <your-dockerhub-username>/dockerized_app:latest
  1. Push the Image:
docker push mobasserulhaque/mh_de_week12:tagname
  1. Pull the Image:
docker pull mobasserulhaque/mh_de_week12:latest

DockerHub_Repo_Img2 DockerHub_Repo_Img3

Using Make Commands

Alternatively, use the following command to simplify the process:

make push

Docker Hub Details


About

Dockerized Application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published