Update README.md
This commit is contained in:
parent
47ee1ec2b2
commit
536a7928c4
138
README.md
138
README.md
@ -1,136 +1,38 @@
|
|||||||
\# Web Application Docker Deployment Documentation
|
# WebApp Docker Deployment
|
||||||
Conditions for Deploying and Running the Application
|
|
||||||
To deploy and run this web application, the following software must be installed on your system:
|
|
||||||
|
|
||||||
# Docker
|
# Requirements -
|
||||||
Install Docker (with Docker Compose) to create and manage containers.
|
|
||||||
|
|
||||||
# Git
|
Docker installed
|
||||||
Ensure Git is installed if you're cloning the project repository.
|
|
||||||
|
|
||||||
# A terminal/command-line interface
|
Docker Compose (optional)
|
||||||
You will need a terminal for executing shell scripts and commands.
|
|
||||||
|
|
||||||
# A web browser
|
# Description -
|
||||||
Used to access the web application once it is deployed (recommended: Google Chrome or Mozilla Firefox).
|
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
|
# Networks and Volumes -
|
||||||
This application is a basic PHP web application connected to a MySQL database. It consists of the following components:
|
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.
|
A volume to persist database data.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
# Container Configuration
|
# Container Configuration
|
||||||
The application consists of the following Docker containers:
|
apache: Web service running Apache with PHP, exposes port 8080.
|
||||||
|
|
||||||
1. Apache-PHP Container
|
# mysql -
|
||||||
Service Name: apache
|
|
||||||
|
|
||||||
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
|
Remove the application: ./remove-app.sh
|
||||||
Service Name: mysql
|
|
||||||
|
|
||||||
Image: Official mysql image.
|
# Accessing the Application
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
Open a web browser and navigate to http://localhost:8080.
|
Loading…
Reference in New Issue
Block a user