diff --git a/z1/Dockerfile b/z1/Dockerfile new file mode 100644 index 0000000..538f77c --- /dev/null +++ b/z1/Dockerfile @@ -0,0 +1,15 @@ +# Используем официальный образ Nginx +FROM nginx:latest + +# Копируем конфиг файлы в контейнер +COPY nginx/nginx.conf /etc/nginx/nginx.conf +COPY nginx/default.conf /etc/nginx/conf.d/default.conf + +# Копируем содержимое вашего веб-приложения в контейнер +COPY ./app /usr/share/nginx/html + +# Открываем порт 80 для веб-сервера +EXPOSE 80 + +# Запускаем Nginx +CMD ["nginx", "-g", "daemon off;"] diff --git a/z1/README.md b/z1/README.md new file mode 100644 index 0000000..55750c9 --- /dev/null +++ b/z1/README.md @@ -0,0 +1,67 @@ +# Docker Web Application with MySQL and Nginx + +## 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. +``` diff --git a/z1/Yan .zip b/z1/Yan .zip new file mode 100644 index 0000000..e95dfb8 Binary files /dev/null and b/z1/Yan .zip differ diff --git a/z1/default.conf b/z1/default.conf new file mode 100644 index 0000000..7a219e9 --- /dev/null +++ b/z1/default.conf @@ -0,0 +1,23 @@ +# default.conf +server { + listen 80; + + server_name localhost; + + # Путь до вашего веб-приложения + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + # Для обработки ошибок + error_page 404 /404.html; + location = /404.html { + root /usr/share/nginx/html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/z1/docker-compose.yml b/z1/docker-compose.yml new file mode 100644 index 0000000..de2550b --- /dev/null +++ b/z1/docker-compose.yml @@ -0,0 +1,31 @@ +version: "3.7" +services: + web: + build: + context: . + ports: + - "80:80" + volumes: + - ./app:/usr/share/nginx/html + - ./nginx/nginx.conf:/etc/nginx/nginx.conf + - ./nginx/default.conf:/etc/nginx/conf.d/default.conf + networks: + - app-network + restart: always + db: + image: mysql:5.7 + environment: + MYSQL_ROOT_PASSWORD: example + volumes: + - db_data:/var/lib/mysql + networks: + - app-network + restart: always + +volumes: + db_data: + +networks: + app-network: + driver: bridge + \ No newline at end of file diff --git a/z1/index.html b/z1/index.html new file mode 100644 index 0000000..f1517b1 --- /dev/null +++ b/z1/index.html @@ -0,0 +1,2 @@ +mkdir app +echo "