Skip to content

A simple yet practical Python Flask web application integrated with Redis and containerized using Docker, then orchestrated with Docker Compose. This project demonstrates how to build and run a multi-container application, where Flask communicates with Redis to store a hit counter, all within a consistent and reproducible environment. The setup ena

Notifications You must be signed in to change notification settings

Belal2015/deploy-webApp-python-flask-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Deploy Web Application — Flask + Redis (Docker & Docker Compose)

A minimal Python Flask web application containerized with Docker and orchestrated using Docker Compose. The application demonstrates a simple hit counter stored in Redis, showcasing backend + DevOps fundamentals.


📌 Project Overview

This project demonstrates how to build, containerize, and deploy a Flask web application using Docker. It uses Redis as a backend service to store a hit counter and shows how multiple services communicate using Docker Compose.

The project is beginner-friendly and suitable for learning:

  • Flask basics
  • Docker & Docker Compose
  • Service-to-service communication
  • Deployment-ready project structure

✨ Features

  • Python Flask web application
  • Redis used as a hit counter
  • Dockerfile for building the application image
  • Docker Compose for multi-container orchestration
  • Clean project structure with screenshots for documentation

🛠 Technologies Used

  • Python
  • Flask
  • Redis
  • Docker
  • Docker Compose
  • Git & GitHub

📂 Project Structure

deploy-webApplication-python-flask/
├── app.py
├── requirements.txt
├── Dockerfile
├── docker-compose.yaml
├── README.md
└── screenshot/

📸 Screenshots

🔹 Project Files

Shows Flask source code and Docker configuration (click to enlarge):

  • DockerfileDockerfile
  • docker-compose.yamldocker-compose.yaml

🔹 Docker Images & Containers

Output and container screenshots:

docker image ls

docker images

docker ps

containers

🔹 Application Running (Browser Refresh)

Sequence showing the hit counter incrementing in the browser:

  • Refresh 1: refresh-1
  • Refresh 3: refresh-3
  • Refresh 5: refresh-5

⚙️ Prerequisites

  • Docker (Engine)
  • Docker Compose
  • Optional: Python 3.9+ for local development

🚀 Quick Start (Recommended — Docker Compose)

From the project root (where docker-compose.yaml exists):

docker-compose up --build

Open your browser:

http://localhost:3000

To stop and remove containers:

docker-compose down

▶️ Run Locally (Without Docker)

python -m venv .venv

# Windows PowerShell
.venv\Scripts\Activate

pip install -r requirements.txt
python app.py

The app will be available at:

http://localhost:5000

🔧 Configuration & Environment Variables

Variable Default Description
FLASK_DEBUG false Enable Flask debug mode
REDIS_HOST redis Redis service name (Docker Compose)
REDIS_PORT 6379 Redis port

Docker Compose maps:

Host: 3000 → Container: 5000

🧪 Development

For rapid development:

docker-compose up

Code changes are reflected immediately when using volumes (if enabled). Unit tests can be added later using pytest.


🛠 Troubleshooting

  • Redis connection issue

    docker-compose ps
    docker logs my-container_redis
  • Port 3000 already in use Change the host port mapping in docker-compose.yaml.


🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
git checkout -b feat/your-feature
  1. Commit your changes and open a Pull Request

👤 Author

Belal Mahmoud DevOps Engineer


📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

d1cf437 (add README.md)

About

A simple yet practical Python Flask web application integrated with Redis and containerized using Docker, then orchestrated with Docker Compose. This project demonstrates how to build and run a multi-container application, where Flask communicates with Redis to store a hit counter, all within a consistent and reproducible environment. The setup ena

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published