68 lines
1.3 KiB
Markdown
68 lines
1.3 KiB
Markdown
# Docker Web Application with MySQL and Nginx (zkt2025)
|
|
|
|
## Requirements
|
|
- Docker
|
|
- Docker Compose
|
|
|
|
## Description
|
|
This web application consists of two services:
|
|
1. A **web service** using Nginx to serve static HTML files.
|
|
2. A **database service** using MySQL, which persists its data in a Docker volume.
|
|
|
|
## Docker Volumes and Networks
|
|
- **Volume**: `db_data` - used to persist MySQL data.
|
|
- **Network**: `app-network` - internal network for the services to communicate.
|
|
|
|
## Configuration
|
|
- **Nginx**: Serves static HTML files from the `/html` directory.
|
|
- **MySQL**: Configured with `MYSQL_ROOT_PASSWORD` and a default database `mydb`.
|
|
|
|
## How to Use
|
|
|
|
### Preparing the app
|
|
Run the following command to prepare the application:
|
|
```bash
|
|
./prepare-app.sh
|
|
```
|
|
|
|
### Starting the app
|
|
To start the app, run:
|
|
```bash
|
|
./start-app.sh
|
|
```
|
|
|
|
The app will be available at `http://localhost:5000`.
|
|
|
|
### Stopping the app
|
|
To stop the app, run:
|
|
```bash
|
|
./stop-app.sh
|
|
```
|
|
|
|
### Removing the app
|
|
To remove all resources related to the app, run:
|
|
```bash
|
|
./remove-app.sh
|
|
```
|
|
|
|
## Example usage
|
|
|
|
```bash
|
|
# Prepare the app
|
|
./prepare-app.sh
|
|
Preparing app...
|
|
|
|
# Start the app
|
|
./start-app.sh
|
|
Running app ...
|
|
The app is available at http://localhost:5000
|
|
|
|
# Stop the app
|
|
./stop-app.sh
|
|
Stopping app...
|
|
|
|
# Remove the app
|
|
./remove-app.sh
|
|
Removed app.
|
|
```
|