kosheev_maksim_lab_2 is ready
This commit is contained in:
parent
3b9698ac38
commit
20acae9135
0
kosheev_maksim_lab_2/.gitignote
Normal file
0
kosheev_maksim_lab_2/.gitignote
Normal file
0
kosheev_maksim_lab_2/README.md
Normal file
0
kosheev_maksim_lab_2/README.md
Normal file
11
kosheev_maksim_lab_2/data_generator/Dockerfile
Normal file
11
kosheev_maksim_lab_2/data_generator/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Используем Python-образ
|
||||||
|
FROM python:3.9
|
||||||
|
|
||||||
|
# Копируем скрипт генерации данных
|
||||||
|
COPY generate_data.py /app/generate_data.py
|
||||||
|
|
||||||
|
# Устанавливаем рабочую директорию
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Запускаем скрипт
|
||||||
|
ENTRYPOINT ["python", "generate_data.py"]
|
0
kosheev_maksim_lab_2/docker-compose.yml
Normal file
0
kosheev_maksim_lab_2/docker-compose.yml
Normal file
0
kosheev_maksim_lab_2/worker-1/Dockerfile
Normal file
0
kosheev_maksim_lab_2/worker-1/Dockerfile
Normal file
0
kosheev_maksim_lab_2/worker-1/main.py
Normal file
0
kosheev_maksim_lab_2/worker-1/main.py
Normal file
11
kosheev_maksim_lab_2/worker-2/Dockerfile
Normal file
11
kosheev_maksim_lab_2/worker-2/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Используем образ Python
|
||||||
|
FROM python:3.9-slim
|
||||||
|
|
||||||
|
# Создаем рабочий каталог
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Копируем скрипт в контейнер
|
||||||
|
COPY main.py .
|
||||||
|
|
||||||
|
# Команда для запуска программы
|
||||||
|
CMD ["python", "main.py"]
|
16
kosheev_maksim_lab_2/worker-2/main.py
Normal file
16
kosheev_maksim_lab_2/worker-2/main.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
input_dir = '/var/data'
|
||||||
|
output_file = '/var/result/data.txt'
|
||||||
|
|
||||||
|
def get_first_line_from_files(input_directory, output_path):
|
||||||
|
with open(output_path, 'w') as outfile:
|
||||||
|
for filename in os.listdir(input_directory):
|
||||||
|
file_path = os.path.join(input_directory, filename)
|
||||||
|
if os.path.isfile(file_path):
|
||||||
|
with open(file_path, 'r') as infile:
|
||||||
|
first_line = infile.readline().strip()
|
||||||
|
outfile.write(first_line + '\n')
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
get_first_line_from_files(input_dir, output_file)
|
Loading…
Reference in New Issue
Block a user