forked from Alexey/DAS_2023_1
старт
This commit is contained in:
parent
0227f5eaa0
commit
23dfef9856
5
.idea/misc.xml
generated
5
.idea/misc.xml
generated
@ -1,5 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager">
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
|
||||||
</component>
|
|
||||||
</project>
|
</project>
|
67
antonov_dmitry_lab_3/README.md
Normal file
67
antonov_dmitry_lab_3/README.md
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# Лабораторная работа №1 - Знакомство с docker и docker-compose
|
||||||
|
|
||||||
|
Разверните 3 сервиса на выбор в контейнерах docker с помощью docker-compose.
|
||||||
|
Требования и docker-compose:
|
||||||
|
|
||||||
|
Несколько контейнеров.
|
||||||
|
Хотя бы один volume.
|
||||||
|
Хотя бы один порт, проброшенный на хост.
|
||||||
|
При этом разворачивание системы должно пройти до конца. Например, должен быть создан
|
||||||
|
администратор и система должна корректно функционировать. Это необходимо будет предоставить
|
||||||
|
в отчёте, поэтому не забывайте делать скриншоты.
|
||||||
|
|
||||||
|
# Выбранные сервисы
|
||||||
|
|
||||||
|
* mediawiki - движок вики
|
||||||
|
* drupal - популярная система управления контентом
|
||||||
|
* wordpress - популярная система управления контентом.
|
||||||
|
|
||||||
|
# Запуск
|
||||||
|
|
||||||
|
Командой в консоли проекта "docker-compose up -d"
|
||||||
|
|
||||||
|
# Описание работы:
|
||||||
|
Развернули три сервиса плюс базу данных к ним.
|
||||||
|
Подробное описание для docker-compose дано в комментариях.
|
||||||
|
|
||||||
|
1. mediawiki:
|
||||||
|
- доступ на http://localhost:8080/
|
||||||
|
|
||||||
|
2. drupal:
|
||||||
|
- доступ на http://localhost:8081/
|
||||||
|
|
||||||
|
3. wordpress:
|
||||||
|
- доступ на http://localhost:8082/
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<div>Старт сервисов</div>
|
||||||
|
<img src="screens/img.png" width="650" title="Старт сервисов">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div>Сервисы</div>
|
||||||
|
<img src="screens/img_1.png" width="650" title="Сервисы">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div>Images</div>
|
||||||
|
<img src="screens/img_2.png" width="650" title="Сервисы">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div>Volumes</div>
|
||||||
|
<img src="screens/img_3.png" width="650" title="Сервисы">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div>Сервис 1</div>
|
||||||
|
<img src="screens/img_4.png" width="650" title="Сервис 1">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div>Сервис 2</div>
|
||||||
|
<img src="screens/img_5.png" width="650" title="Сервис 2">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div>Сервис 3</div>
|
||||||
|
<img src="screens/img_6.png" width="650" title="Сервис 3">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
# Ссылка на видео
|
||||||
|
https://disk.yandex.ru/i/nG5KrHy_DsQxuw
|
||||||
|
|
23
antonov_dmitry_lab_3/docker-compose.yml
Normal file
23
antonov_dmitry_lab_3/docker-compose.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
service_a:
|
||||||
|
build: ./service_a
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
|
|
||||||
|
service_b:
|
||||||
|
build: ./service_b
|
||||||
|
ports:
|
||||||
|
- "5001:5001"
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
volumes:
|
||||||
|
- ./service_a.conf:/etc/nginx/conf.d/service_a.conf
|
||||||
|
- ./service_b.conf:/etc/nginx/conf.d/service_b.conf
|
||||||
|
depends_on:
|
||||||
|
- service_a
|
||||||
|
- service_b
|
8
antonov_dmitry_lab_3/service_a.conf
Normal file
8
antonov_dmitry_lab_3/service_a.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name service_a;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://service_a:5000;
|
||||||
|
}
|
||||||
|
}
|
13
antonov_dmitry_lab_3/service_a/Dockerfile
Normal file
13
antonov_dmitry_lab_3/service_a/Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM python:3.8-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
ENV NAME service_a
|
||||||
|
|
||||||
|
CMD ["python", "app.py"]
|
38
antonov_dmitry_lab_3/service_a/app.py
Normal file
38
antonov_dmitry_lab_3/service_a/app.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from flask import Flask, jsonify, request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
# хранение данных сущности A
|
||||||
|
entity_a_data = []
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/entity_a', methods=['GET'])
|
||||||
|
def get_entity_a():
|
||||||
|
return jsonify(entity_a_data)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/entity_a', methods=['POST'])
|
||||||
|
def create_entity_a():
|
||||||
|
new_entity = request.json
|
||||||
|
entity_a_data.append(new_entity)
|
||||||
|
return jsonify(new_entity), 201
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/entity_a/<int:id>', methods=['PUT'])
|
||||||
|
def update_entity_a(id):
|
||||||
|
for entity in entity_a_data:
|
||||||
|
if entity['id'] == id:
|
||||||
|
entity.update(request.json)
|
||||||
|
return jsonify(entity), 200
|
||||||
|
return jsonify({'error': 'Entity not found'}), 404
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/entity_a/<int:id>', methods=['DELETE'])
|
||||||
|
def delete_entity_a(id):
|
||||||
|
global entity_a_data
|
||||||
|
entity_a_data = [entity for entity in entity_a_data if entity['id'] != id]
|
||||||
|
return jsonify({'message': 'Entity deleted'}), 200
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0', port=5000)
|
1
antonov_dmitry_lab_3/service_a/requirements.txt
Normal file
1
antonov_dmitry_lab_3/service_a/requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Flask
|
8
antonov_dmitry_lab_3/service_b.conf
Normal file
8
antonov_dmitry_lab_3/service_b.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name service_b;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://service_b:5001;
|
||||||
|
}
|
||||||
|
}
|
13
antonov_dmitry_lab_3/service_b/Dockerfile
Normal file
13
antonov_dmitry_lab_3/service_b/Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM python:3.8-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
EXPOSE 5001
|
||||||
|
|
||||||
|
ENV NAME service_b
|
||||||
|
|
||||||
|
CMD ["python", "app.py"]
|
38
antonov_dmitry_lab_3/service_b/app.py
Normal file
38
antonov_dmitry_lab_3/service_b/app.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from flask import Flask, jsonify, request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
# хранение данных сущности B
|
||||||
|
entity_b_data = []
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/entity_b', methods=['GET'])
|
||||||
|
def get_entity_b():
|
||||||
|
return jsonify(entity_b_data)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/entity_b', methods=['POST'])
|
||||||
|
def create_entity_b():
|
||||||
|
new_entity = request.json
|
||||||
|
entity_b_data.append(new_entity)
|
||||||
|
return jsonify(new_entity), 201
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/entity_b/<int:id>', methods=['PUT'])
|
||||||
|
def update_entity_b(id):
|
||||||
|
for entity in entity_b_data:
|
||||||
|
if entity['id'] == id:
|
||||||
|
entity.update(request.json)
|
||||||
|
return jsonify(entity), 200
|
||||||
|
return jsonify({'error': 'Entity not found'}), 404
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/entity_b/<int:id>', methods=['DELETE'])
|
||||||
|
def delete_entity_b(id):
|
||||||
|
global entity_b_data
|
||||||
|
entity_b_data = [entity for entity in entity_b_data if entity['id'] != id]
|
||||||
|
return jsonify({'message': 'Entity deleted'}), 200
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0', port=5001)
|
1
antonov_dmitry_lab_3/service_b/requirements.txt
Normal file
1
antonov_dmitry_lab_3/service_b/requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Flask
|
Loading…
x
Reference in New Issue
Block a user