From 536a7928c4ae77eb2791981c30ef82a6b885a035 Mon Sep 17 00:00:00 2001 From: Puneet Khurana Date: Wed, 2 Apr 2025 07:15:09 +0000 Subject: [PATCH] Update README.md --- README.md | 138 ++++++++---------------------------------------------- 1 file changed, 20 insertions(+), 118 deletions(-) diff --git a/README.md b/README.md index b6fd8b8..7b6ec8d 100644 --- a/README.md +++ b/README.md @@ -1,136 +1,38 @@ -\# Web Application Docker Deployment Documentation -Conditions for Deploying and Running the Application -To deploy and run this web application, the following software must be installed on your system: +# WebApp Docker Deployment -# Docker -Install Docker (with Docker Compose) to create and manage containers. +# Requirements - -# Git -Ensure Git is installed if you're cloning the project repository. +Docker installed -# A terminal/command-line interface -You will need a terminal for executing shell scripts and commands. +Docker Compose (optional) -# A web browser -Used to access the web application once it is deployed (recommended: Google Chrome or Mozilla Firefox). +# Description - +This application consists of a web service and a database service. The web service runs on an Apache server with PHP and connects to a MySQL database. -# Description of the Application -This application is a basic PHP web application connected to a MySQL database. It consists of the following components: +# Networks and Volumes - +my_network: A bridge network for inter-container communication. -Apache Web Server with PHP: The Apache service runs the PHP application and serves it through the web server. +# mysql_data - -MySQL Database: A MySQL database that stores user data and other application-related information. - -Persistence Mechanism: Uses Docker volumes to ensure that data stored in the MySQL database persists even after the containers are stopped or removed. - -Virtual Networks and Named Volumes Used by the Application -Network: -The containers are connected via a custom Docker bridge network named my_network. This allows communication between the Apache-PHP service and the MySQL service. - -# Named Volume: - -mysql_data: A named volume used to store the database data persistently. This ensures that even if the containers are removed or recreated, the database data will be preserved. +A volume to persist database data. # Container Configuration -The application consists of the following Docker containers: +apache: Web service running Apache with PHP, exposes port 8080. -1. Apache-PHP Container -Service Name: apache +# mysql - -Image: Official php:apache image. +MySQL database service using the official MySQL image, exposes port 3306. -Ports: +# Instructions -Exposes port 8080 for accessing the web application through a browser. +Prepare the application: ./prepare-app.sh -Volume Mapping: +Start the application: ./start-app.sh -Maps the app directory from the host machine to the container, where the PHP files are stored and served. +Stop the application: ./stop-app.sh -2. MySQL Container -Service Name: mysql +Remove the application: ./remove-app.sh -Image: Official mysql image. - -Ports: - -Exposes port 3306 for database communication (typically used for internal communication with the Apache-PHP container). - -# Volume Mapping: - -Uses a named volume mysql_data for persisting database data. - -# Containers Used and Brief Description -apache: -This container runs the Apache web server with PHP support. It serves the PHP files that are located in the app directory. - -mysql: -This container runs the MySQL database. It stores and manages the data for the PHP application, using the mysql_data volume for persistence. - -Instructions on How to Prepare, Run, Pause, and Delete the Application -1. Prepare the Application -To set up the necessary network and volume, run the following command: - -bash -Copy -Edit -./prepare-app.sh -This script will: - -Create the custom Docker network (my_network). - -Create the named volume (mysql_data). - -Set up the application directory and create a test PHP file. - -2. Start the Application -To start the application and run the containers in detached mode, execute: - -bash -Copy -Edit -./start-app.sh -This script will: - -Start the Docker containers (apache and mysql). - -Wait for a few seconds to ensure all services are up and running. - -Display a message with the URL to access the web application. - -3. Pause the Application -To stop the running containers without deleting data, use: - -bash -Copy -Edit -./stop-app.sh -This will: - -Stop the containers (apache and mysql). - -4. Delete the Application -To completely remove the containers, networks, and volumes, run: - -bash -Copy -Edit -./remove-app.sh -This will: - -# Remove the apache and mysql containers. - -# Delete the custom Docker network and the named volume mysql_data. - -# Instructions on How to View the Application on the Web -Once the application is running, open a web browser and navigate to: - -plaintext -Copy -Edit -# http://localhost:8080/index.php -This page will test the connection to the MySQL database. If the connection is successful, a confirmation message will be displayed. - -# Conclusion -This project demonstrates how to deploy a simple PHP application with a MySQL database using Docker. By using Docker Compose, the application ensures modularity and ease of deployment, while the named volume ensures that database data is persisted across container restarts. +# Accessing the Application +Open a web browser and navigate to http://localhost:8080. \ No newline at end of file