diff --git a/aleikin_artem_lab_2/MySolution/.dockerignore b/aleikin_artem_lab_2/MySolution/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp1/ConsoleApp1.csproj b/aleikin_artem_lab_2/MySolution/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..e076340 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + Linux + + + + + + + diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp1/ConsoleApp1.csproj.user b/aleikin_artem_lab_2/MySolution/ConsoleApp1/ConsoleApp1.csproj.user new file mode 100644 index 0000000..dd2d54c --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp1/ConsoleApp1.csproj.user @@ -0,0 +1,6 @@ + + + + Container (Dockerfile) + + \ No newline at end of file diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp1/Dockerfile b/aleikin_artem_lab_2/MySolution/ConsoleApp1/Dockerfile new file mode 100644 index 0000000..89d5c07 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp1/Dockerfile @@ -0,0 +1,28 @@ +# См. статью по ссылке https://aka.ms/customizecontainer, чтобы узнать как настроить контейнер отладки и как Visual Studio использует этот Dockerfile для создания образов для ускорения отладки. + +# Этот этап используется при запуске из VS в быстром режиме (по умолчанию для конфигурации отладки) +FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base +USER app +WORKDIR /app + + +# Этот этап используется для сборки проекта службы +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["ConsoleApp1/ConsoleApp1.csproj", "ConsoleApp1/"] +RUN dotnet restore "./ConsoleApp1/ConsoleApp1.csproj" +COPY . . +WORKDIR "/src/ConsoleApp1" +RUN dotnet build "./ConsoleApp1.csproj" -c $BUILD_CONFIGURATION -o /app/build + +# Этот этап используется для публикации проекта службы, который будет скопирован на последний этап +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./ConsoleApp1.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +# Этот этап используется в рабочей среде или при запуске из VS в обычном режиме (по умолчанию, когда конфигурация отладки не используется) +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "ConsoleApp1.dll"] \ No newline at end of file diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp1/Program.cs b/aleikin_artem_lab_2/MySolution/ConsoleApp1/Program.cs new file mode 100644 index 0000000..97094e5 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp1/Program.cs @@ -0,0 +1,36 @@ +using System; +using System.IO; + +class Program +{ + static void Main() + { + const string inputDir = "/var/data"; + const string outputFile = "/var/result/data.txt"; + + try + { + using (var writer = new StreamWriter(outputFile)) + { + var files = Directory.GetFiles(inputDir); + foreach (var file in files) + { + using (var reader = new StreamReader(file)) + { + string firstLine = reader.ReadLine(); + if (!string.IsNullOrEmpty(firstLine)) + { + writer.WriteLine(firstLine); + } + } + } + } + + Console.WriteLine($"Файл {outputFile} успешно создан."); + } + catch (Exception ex) + { + Console.WriteLine($"Ошибка: {ex.Message}"); + } + } +} diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp1/Properties/launchSettings.json b/aleikin_artem_lab_2/MySolution/ConsoleApp1/Properties/launchSettings.json new file mode 100644 index 0000000..1fc0367 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp1/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "ConsoleApp1": { + "commandName": "Project" + }, + "Container (Dockerfile)": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp2/ConsoleApp2.csproj b/aleikin_artem_lab_2/MySolution/ConsoleApp2/ConsoleApp2.csproj new file mode 100644 index 0000000..e076340 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp2/ConsoleApp2.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + Linux + + + + + + + diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp2/ConsoleApp2.csproj.user b/aleikin_artem_lab_2/MySolution/ConsoleApp2/ConsoleApp2.csproj.user new file mode 100644 index 0000000..dd2d54c --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp2/ConsoleApp2.csproj.user @@ -0,0 +1,6 @@ + + + + Container (Dockerfile) + + \ No newline at end of file diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp2/Dockerfile b/aleikin_artem_lab_2/MySolution/ConsoleApp2/Dockerfile new file mode 100644 index 0000000..3c2029a --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp2/Dockerfile @@ -0,0 +1,28 @@ +# См. статью по ссылке https://aka.ms/customizecontainer, чтобы узнать как настроить контейнер отладки и как Visual Studio использует этот Dockerfile для создания образов для ускорения отладки. + +# Этот этап используется при запуске из VS в быстром режиме (по умолчанию для конфигурации отладки) +FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base +USER app +WORKDIR /app + + +# Этот этап используется для сборки проекта службы +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["ConsoleApp2/ConsoleApp2.csproj", "ConsoleApp2/"] +RUN dotnet restore "./ConsoleApp2/ConsoleApp2.csproj" +COPY . . +WORKDIR "/src/ConsoleApp2" +RUN dotnet build "./ConsoleApp2.csproj" -c $BUILD_CONFIGURATION -o /app/build + +# Этот этап используется для публикации проекта службы, который будет скопирован на последний этап +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./ConsoleApp2.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +# Этот этап используется в рабочей среде или при запуске из VS в обычном режиме (по умолчанию, когда конфигурация отладки не используется) +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "ConsoleApp2.dll"] \ No newline at end of file diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp2/Program.cs b/aleikin_artem_lab_2/MySolution/ConsoleApp2/Program.cs new file mode 100644 index 0000000..34d5a55 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp2/Program.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using System.Linq; + +class Program +{ + static void Main() + { + const string inputFile = "/var/result/data.txt"; + const string outputFile = "/var/result/result.txt"; + + try + { + var lines = File.ReadAllLines(inputFile).Select(int.Parse).ToArray(); + + if (lines.Length >= 2) + { + int result = lines.First() * lines.Last(); + + File.WriteAllText(outputFile, result.ToString()); + + Console.WriteLine($"Произведение: {result}"); + } + else + { + Console.WriteLine("Недостаточно данных в файле для вычисления."); + } + } + catch (Exception ex) + { + Console.WriteLine($"Ошибка: {ex.Message}"); + } + } +} diff --git a/aleikin_artem_lab_2/MySolution/ConsoleApp2/Properties/launchSettings.json b/aleikin_artem_lab_2/MySolution/ConsoleApp2/Properties/launchSettings.json new file mode 100644 index 0000000..7d85e14 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/ConsoleApp2/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "ConsoleApp2": { + "commandName": "Project" + }, + "Container (Dockerfile)": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/aleikin_artem_lab_2/MySolution/MySolution.sln b/aleikin_artem_lab_2/MySolution/MySolution.sln new file mode 100644 index 0000000..8e189b9 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/MySolution.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35312.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{4AA3FE7B-3074-4C88-B656-329CA0775E84}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{B58DA2CC-FFDF-4B55-8499-2B66B9C092DC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4AA3FE7B-3074-4C88-B656-329CA0775E84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AA3FE7B-3074-4C88-B656-329CA0775E84}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AA3FE7B-3074-4C88-B656-329CA0775E84}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AA3FE7B-3074-4C88-B656-329CA0775E84}.Release|Any CPU.Build.0 = Release|Any CPU + {B58DA2CC-FFDF-4B55-8499-2B66B9C092DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B58DA2CC-FFDF-4B55-8499-2B66B9C092DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B58DA2CC-FFDF-4B55-8499-2B66B9C092DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B58DA2CC-FFDF-4B55-8499-2B66B9C092DC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9FA7820A-6879-4F32-A304-59D3FAA51A8C} + EndGlobalSection +EndGlobal diff --git a/aleikin_artem_lab_2/MySolution/data/file1.txt b/aleikin_artem_lab_2/MySolution/data/file1.txt new file mode 100644 index 0000000..0802ff4 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file1.txt @@ -0,0 +1,10 @@ +25 +91 +77 +63 +45 +25 +21 +89 +6 +18 diff --git a/aleikin_artem_lab_2/MySolution/data/file10.txt b/aleikin_artem_lab_2/MySolution/data/file10.txt new file mode 100644 index 0000000..c1de5de --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file10.txt @@ -0,0 +1,10 @@ +10 +3 +38 +9 +36 +43 +96 +31 +95 +58 diff --git a/aleikin_artem_lab_2/MySolution/data/file11.txt b/aleikin_artem_lab_2/MySolution/data/file11.txt new file mode 100644 index 0000000..08e394e --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file11.txt @@ -0,0 +1,10 @@ +13 +35 +38 +31 +19 +94 +94 +84 +18 +47 diff --git a/aleikin_artem_lab_2/MySolution/data/file12.txt b/aleikin_artem_lab_2/MySolution/data/file12.txt new file mode 100644 index 0000000..1878889 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file12.txt @@ -0,0 +1,10 @@ +9 +32 +75 +92 +100 +85 +85 +10 +50 +54 diff --git a/aleikin_artem_lab_2/MySolution/data/file13.txt b/aleikin_artem_lab_2/MySolution/data/file13.txt new file mode 100644 index 0000000..291d14a --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file13.txt @@ -0,0 +1,10 @@ +83 +88 +29 +86 +87 +79 +18 +22 +76 +71 diff --git a/aleikin_artem_lab_2/MySolution/data/file14.txt b/aleikin_artem_lab_2/MySolution/data/file14.txt new file mode 100644 index 0000000..a26cc0f --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file14.txt @@ -0,0 +1,10 @@ +15 +22 +92 +91 +78 +47 +53 +98 +72 +64 diff --git a/aleikin_artem_lab_2/MySolution/data/file15.txt b/aleikin_artem_lab_2/MySolution/data/file15.txt new file mode 100644 index 0000000..cefdc21 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file15.txt @@ -0,0 +1,10 @@ +66 +45 +83 +55 +25 +82 +95 +42 +18 +6 diff --git a/aleikin_artem_lab_2/MySolution/data/file16.txt b/aleikin_artem_lab_2/MySolution/data/file16.txt new file mode 100644 index 0000000..999ea8b --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file16.txt @@ -0,0 +1,10 @@ +25 +71 +35 +71 +78 +51 +29 +67 +87 +33 diff --git a/aleikin_artem_lab_2/MySolution/data/file17.txt b/aleikin_artem_lab_2/MySolution/data/file17.txt new file mode 100644 index 0000000..eb0014f --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file17.txt @@ -0,0 +1,10 @@ +93 +19 +32 +13 +75 +86 +46 +87 +39 +66 diff --git a/aleikin_artem_lab_2/MySolution/data/file18.txt b/aleikin_artem_lab_2/MySolution/data/file18.txt new file mode 100644 index 0000000..7926296 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file18.txt @@ -0,0 +1,10 @@ +7 +74 +69 +75 +45 +28 +92 +9 +77 +32 diff --git a/aleikin_artem_lab_2/MySolution/data/file19.txt b/aleikin_artem_lab_2/MySolution/data/file19.txt new file mode 100644 index 0000000..f2c93c1 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file19.txt @@ -0,0 +1,10 @@ +42 +75 +67 +53 +2 +34 +57 +47 +83 +52 diff --git a/aleikin_artem_lab_2/MySolution/data/file2.txt b/aleikin_artem_lab_2/MySolution/data/file2.txt new file mode 100644 index 0000000..591d1bf --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file2.txt @@ -0,0 +1,10 @@ +98 +62 +45 +77 +65 +45 +61 +62 +10 +76 diff --git a/aleikin_artem_lab_2/MySolution/data/file20.txt b/aleikin_artem_lab_2/MySolution/data/file20.txt new file mode 100644 index 0000000..d40cb4c --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file20.txt @@ -0,0 +1,10 @@ +41 +30 +41 +39 +62 +3 +79 +93 +56 +82 diff --git a/aleikin_artem_lab_2/MySolution/data/file21.txt b/aleikin_artem_lab_2/MySolution/data/file21.txt new file mode 100644 index 0000000..cde3f8a --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file21.txt @@ -0,0 +1,10 @@ +85 +29 +46 +36 +82 +52 +4 +14 +89 +17 diff --git a/aleikin_artem_lab_2/MySolution/data/file22.txt b/aleikin_artem_lab_2/MySolution/data/file22.txt new file mode 100644 index 0000000..0e4331c --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file22.txt @@ -0,0 +1,10 @@ +35 +98 +38 +31 +39 +76 +5 +71 +7 +58 diff --git a/aleikin_artem_lab_2/MySolution/data/file23.txt b/aleikin_artem_lab_2/MySolution/data/file23.txt new file mode 100644 index 0000000..8a1d696 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file23.txt @@ -0,0 +1,10 @@ +50 +93 +18 +76 +13 +62 +16 +45 +65 +25 diff --git a/aleikin_artem_lab_2/MySolution/data/file24.txt b/aleikin_artem_lab_2/MySolution/data/file24.txt new file mode 100644 index 0000000..1622200 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file24.txt @@ -0,0 +1,10 @@ +98 +45 +1 +52 +14 +7 +56 +38 +7 +50 diff --git a/aleikin_artem_lab_2/MySolution/data/file25.txt b/aleikin_artem_lab_2/MySolution/data/file25.txt new file mode 100644 index 0000000..7cbba40 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file25.txt @@ -0,0 +1,10 @@ +41 +27 +27 +24 +76 +36 +19 +87 +83 +35 diff --git a/aleikin_artem_lab_2/MySolution/data/file26.txt b/aleikin_artem_lab_2/MySolution/data/file26.txt new file mode 100644 index 0000000..29845dd --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file26.txt @@ -0,0 +1,10 @@ +16 +5 +95 +36 +20 +60 +79 +46 +61 +77 diff --git a/aleikin_artem_lab_2/MySolution/data/file27.txt b/aleikin_artem_lab_2/MySolution/data/file27.txt new file mode 100644 index 0000000..4803375 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file27.txt @@ -0,0 +1,10 @@ +43 +23 +53 +6 +88 +27 +55 +15 +94 +36 diff --git a/aleikin_artem_lab_2/MySolution/data/file28.txt b/aleikin_artem_lab_2/MySolution/data/file28.txt new file mode 100644 index 0000000..3e7d464 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file28.txt @@ -0,0 +1,10 @@ +62 +95 +50 +65 +13 +56 +74 +37 +99 +93 diff --git a/aleikin_artem_lab_2/MySolution/data/file29.txt b/aleikin_artem_lab_2/MySolution/data/file29.txt new file mode 100644 index 0000000..9fdf972 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file29.txt @@ -0,0 +1,10 @@ +13 +2 +31 +49 +80 +73 +47 +61 +96 +69 diff --git a/aleikin_artem_lab_2/MySolution/data/file3.txt b/aleikin_artem_lab_2/MySolution/data/file3.txt new file mode 100644 index 0000000..9ecd886 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file3.txt @@ -0,0 +1,10 @@ +37 +54 +100 +34 +1 +77 +55 +10 +30 +28 diff --git a/aleikin_artem_lab_2/MySolution/data/file30.txt b/aleikin_artem_lab_2/MySolution/data/file30.txt new file mode 100644 index 0000000..50baae1 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file30.txt @@ -0,0 +1,10 @@ +35 +17 +95 +59 +17 +98 +68 +54 +89 +56 diff --git a/aleikin_artem_lab_2/MySolution/data/file4.txt b/aleikin_artem_lab_2/MySolution/data/file4.txt new file mode 100644 index 0000000..528678d --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file4.txt @@ -0,0 +1,10 @@ +38 +80 +93 +2 +61 +29 +4 +41 +83 +100 diff --git a/aleikin_artem_lab_2/MySolution/data/file5.txt b/aleikin_artem_lab_2/MySolution/data/file5.txt new file mode 100644 index 0000000..262d355 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file5.txt @@ -0,0 +1,10 @@ +40 +61 +30 +92 +84 +37 +79 +81 +98 +88 diff --git a/aleikin_artem_lab_2/MySolution/data/file6.txt b/aleikin_artem_lab_2/MySolution/data/file6.txt new file mode 100644 index 0000000..ce55bc5 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file6.txt @@ -0,0 +1,10 @@ +66 +32 +27 +5 +49 +50 +44 +51 +7 +32 diff --git a/aleikin_artem_lab_2/MySolution/data/file7.txt b/aleikin_artem_lab_2/MySolution/data/file7.txt new file mode 100644 index 0000000..f47bb84 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file7.txt @@ -0,0 +1,10 @@ +9 +46 +16 +27 +14 +78 +6 +45 +26 +99 diff --git a/aleikin_artem_lab_2/MySolution/data/file8.txt b/aleikin_artem_lab_2/MySolution/data/file8.txt new file mode 100644 index 0000000..877fa8f --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file8.txt @@ -0,0 +1,10 @@ +48 +41 +43 +93 +91 +95 +16 +23 +91 +43 diff --git a/aleikin_artem_lab_2/MySolution/data/file9.txt b/aleikin_artem_lab_2/MySolution/data/file9.txt new file mode 100644 index 0000000..d2621d9 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/data/file9.txt @@ -0,0 +1,10 @@ +67 +82 +16 +87 +69 +83 +94 +59 +34 +73 diff --git a/aleikin_artem_lab_2/MySolution/docker-compose.yml b/aleikin_artem_lab_2/MySolution/docker-compose.yml new file mode 100644 index 0000000..ef2daf9 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/docker-compose.yml @@ -0,0 +1,20 @@ +services: + app1: + build: + context: . + dockerfile: ConsoleApp1/Dockerfile + volumes: + - ./data:/var/data + - ./result:/var/result + container_name: app1 + + app2: + build: + context: . + dockerfile: ConsoleApp2/Dockerfile + volumes: + - ./data:/var/data + - ./result:/var/result + container_name: app2 + depends_on: + - app1 diff --git a/aleikin_artem_lab_2/MySolution/readme.md b/aleikin_artem_lab_2/MySolution/readme.md new file mode 100644 index 0000000..5adf8cd --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/readme.md @@ -0,0 +1,97 @@ +# Лабораторная работа 2 - Разработка простейшего распределённого приложения +## ПИбд-42 || Алейкин Артем + +### Описание +В данной лабораторной работе мы изучили способы создания и развертывания простого распределённого приложения. +Для выполнения лабораторной работы в рамках реализации первого проекта был выбран 2-ой вариант, а для второго проекта - 0-ой вариант. +1.2: Формирует файл /var/result/data.txt из первых строк всех файлов каталога /var/data. +2.0: Сохраняет произведение первого и последнего числа из файла /var/data/data.txt в /var/result/result.txt. + +### Docker-compose.yml +``` +services: + app1: + build: + context: . + dockerfile: ConsoleApp1/Dockerfile + volumes: + - ./data:/var/data + - ./result:/var/result + container_name: app1 + + app2: + build: + context: . + dockerfile: ConsoleApp2/Dockerfile + volumes: + - ./data:/var/data + - ./result:/var/result + container_name: app2 + depends_on: + - app1 +``` + +app1: + build: Контейнер для app1 создается с использованием Dockerfile, расположенного в ConsoleApp1/Dockerfile. + volumes: Монтируются две локальные директории: + ./data в /var/data внутри контейнера + ./result в /var/result внутри контейнера + container_name: Контейнер будет называться app1. + +app2: + build: Контейнер для app2 создается с использованием Dockerfile, расположенного в ConsoleApp2/Dockerfile. + volumes: Монтируются те же локальные директории, что и для app1. + container_name: Контейнер будет называться app2. + depends_on: Контейнер app2 зависит от запуска контейнера app1, что означает, что app2 будет запускаться только после того, как контейнер app1 будет готов. + + +### Шаги для запуска: +1. Запуск Docker - Desktop +2. Открыть консоль в папке с docker-compose.yml +3. Ввести команду: +``` +docket-compose up --build +``` + +#### В результате в папке result создаётся два текстовых документа: + +data - результат работы первого проекта +``` +25 +10 +13 +9 +83 +15 +66 +25 +93 +7 +42 +98 +41 +85 +35 +50 +98 +41 +16 +43 +62 +13 +37 +35 +38 +40 +66 +9 +48 +67 +``` +result - результат работы второго проекта +``` +1675 +``` + + +Видео демонстрации работы: https://vk.com/video248424990_456239609?list=ln-jAWvJM5pgqjuzJLU1j \ No newline at end of file diff --git a/aleikin_artem_lab_2/MySolution/result/data.txt b/aleikin_artem_lab_2/MySolution/result/data.txt new file mode 100644 index 0000000..04e1cc3 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/result/data.txt @@ -0,0 +1,30 @@ +25 +10 +13 +9 +83 +15 +66 +25 +93 +7 +42 +98 +41 +85 +35 +50 +98 +41 +16 +43 +62 +13 +37 +35 +38 +40 +66 +9 +48 +67 diff --git a/aleikin_artem_lab_2/MySolution/result/result.txt b/aleikin_artem_lab_2/MySolution/result/result.txt new file mode 100644 index 0000000..f01f376 --- /dev/null +++ b/aleikin_artem_lab_2/MySolution/result/result.txt @@ -0,0 +1 @@ +1675 \ No newline at end of file