# Docker Web Application ## Overview This is a Dockerized web application consisting of two services: - **Web Service:** A simple Python Flask application serving HTTP endpoints. - **Database Service:** A MySQL 8.0 database that stores its data in a persistent volume. The web service demonstrates basic functionality and includes an endpoint (`/dbtest`) to test connectivity with the database service. ## Deployment Requirements - **Docker:** Ensure Docker is installed and running. - **Docker Compose:** Version 3.8 or later is required to run the multi-container application. ## Application Architecture - **Virtual Network:** A custom Docker network `app-network` is used to allow seamless communication between containers. - **Named Volume:** A persistent volume `db_data` is defined to store MySQL database data, ensuring data persistence between container restarts. ## Container Configurations - **Web Service Container:** - **Image:** Custom built from the provided `Dockerfile`. - **Port:** Exposes port `5000`. - **Environment Variables:** Set for database connectivity (e.g., `MYSQL_HOST`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_DATABASE`). - **Restart Policy:** Configured to always restart on failure. - **Database Service Container:** - **Image:** Official `mysql:8.0` image. - **Ports:** Exposes port `3306`. - **Environment Variables:** Defines `MYSQL_ROOT_PASSWORD` and `MYSQL_DATABASE` for initial configuration. - **Volume:** Uses named volume `db_data` for data persistence. - **Restart Policy:** Configured to always restart on failure. ## Used Containers - **web:** The Flask-based web server. - **db:** The MySQL database server. ## How to Use the Application 1. **Prepare the Application:** Run the following command to build images and create required networks/volumes: ```bash ./prepare-app.sh 2. **Start the Application:** Launch the containers with: ```bash ./start-app.sh You should see a message: Running app ... The app is available at http://localhost:5000 3. **Interact with the Application:** • Open your web browser and go to http://localhost:5000 to view the home page. • Visit http://localhost:5000/status for the application status. • Visit http://localhost:5000/dbtest to test the database connectivity. 4. **Stop the Application:** To stop all running services without removing their state: ```bash ./stop-app.sh 5. **Remove the Application:** When you want to completely remove all containers, networks, and volumes: ```bash ./remove-app.sh