diff --git a/kosheev_maksim_lab_2/.gitignote b/kosheev_maksim_lab_2/.gitignote new file mode 100644 index 0000000..e69de29 diff --git a/kosheev_maksim_lab_2/README.md b/kosheev_maksim_lab_2/README.md new file mode 100644 index 0000000..e69de29 diff --git a/kosheev_maksim_lab_2/data_generator/Dockerfile b/kosheev_maksim_lab_2/data_generator/Dockerfile new file mode 100644 index 0000000..7410963 --- /dev/null +++ b/kosheev_maksim_lab_2/data_generator/Dockerfile @@ -0,0 +1,11 @@ +# Используем Python-образ +FROM python:3.9 + +# Копируем скрипт генерации данных +COPY generate_data.py /app/generate_data.py + +# Устанавливаем рабочую директорию +WORKDIR /app + +# Запускаем скрипт +ENTRYPOINT ["python", "generate_data.py"] \ No newline at end of file diff --git a/kosheev_maksim_lab_2/data_generator/generate_data.py b/kosheev_maksim_lab_2/data_generator/generate_data.py new file mode 100644 index 0000000..e69de29 diff --git a/kosheev_maksim_lab_2/docker-compose.yml b/kosheev_maksim_lab_2/docker-compose.yml new file mode 100644 index 0000000..e69de29 diff --git a/kosheev_maksim_lab_2/worker-1/Dockerfile b/kosheev_maksim_lab_2/worker-1/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/kosheev_maksim_lab_2/worker-1/main.py b/kosheev_maksim_lab_2/worker-1/main.py new file mode 100644 index 0000000..e69de29 diff --git a/kosheev_maksim_lab_2/worker-2/Dockerfile b/kosheev_maksim_lab_2/worker-2/Dockerfile new file mode 100644 index 0000000..5a4af21 --- /dev/null +++ b/kosheev_maksim_lab_2/worker-2/Dockerfile @@ -0,0 +1,11 @@ +# Используем образ Python +FROM python:3.9-slim + +# Создаем рабочий каталог +WORKDIR /app + +# Копируем скрипт в контейнер +COPY main.py . + +# Команда для запуска программы +CMD ["python", "main.py"] \ No newline at end of file diff --git a/kosheev_maksim_lab_2/worker-2/main.py b/kosheev_maksim_lab_2/worker-2/main.py new file mode 100644 index 0000000..4c02deb --- /dev/null +++ b/kosheev_maksim_lab_2/worker-2/main.py @@ -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) \ No newline at end of file