diff --git a/kuzarin_maxim_lab_2/.dockerignore b/kuzarin_maxim_lab_2/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/kuzarin_maxim_lab_2/.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/kuzarin_maxim_lab_2/.gitignore b/kuzarin_maxim_lab_2/.gitignore new file mode 100644 index 0000000..53771b6 --- /dev/null +++ b/kuzarin_maxim_lab_2/.gitignore @@ -0,0 +1,490 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp + +# Delete volumes +/volumes + +# Delete .vs folder +/.vs/* diff --git a/kuzarin_maxim_lab_2/DAaS_FileConnections.sln b/kuzarin_maxim_lab_2/DAaS_FileConnections.sln new file mode 100644 index 0000000..a14d564 --- /dev/null +++ b/kuzarin_maxim_lab_2/DAaS_FileConnections.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34916.146 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAaS_FileConnections", "DAaS_FileConnections\DAaS_FileConnections.csproj", "{23B07B06-0AB4-42F8-9753-264639E1D38B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirstApplication", "FirstApplication\FirstApplication.csproj", "{FBC01B2E-C887-42D1-A899-3C4781EF67E9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondApplication", "SecondApplication\SecondApplication.csproj", "{5888DB56-82F2-467D-8F6B-AB94CC4A33B5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {23B07B06-0AB4-42F8-9753-264639E1D38B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23B07B06-0AB4-42F8-9753-264639E1D38B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23B07B06-0AB4-42F8-9753-264639E1D38B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23B07B06-0AB4-42F8-9753-264639E1D38B}.Release|Any CPU.Build.0 = Release|Any CPU + {FBC01B2E-C887-42D1-A899-3C4781EF67E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FBC01B2E-C887-42D1-A899-3C4781EF67E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FBC01B2E-C887-42D1-A899-3C4781EF67E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FBC01B2E-C887-42D1-A899-3C4781EF67E9}.Release|Any CPU.Build.0 = Release|Any CPU + {5888DB56-82F2-467D-8F6B-AB94CC4A33B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5888DB56-82F2-467D-8F6B-AB94CC4A33B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5888DB56-82F2-467D-8F6B-AB94CC4A33B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5888DB56-82F2-467D-8F6B-AB94CC4A33B5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E290B7D1-0F4E-406E-ADF3-8F543C0FA96E} + EndGlobalSection +EndGlobal diff --git a/kuzarin_maxim_lab_2/DAaS_FileConnections/DAaS_FileConnections.csproj b/kuzarin_maxim_lab_2/DAaS_FileConnections/DAaS_FileConnections.csproj new file mode 100644 index 0000000..c54449d --- /dev/null +++ b/kuzarin_maxim_lab_2/DAaS_FileConnections/DAaS_FileConnections.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/kuzarin_maxim_lab_2/DAaS_FileConnections/Program.cs b/kuzarin_maxim_lab_2/DAaS_FileConnections/Program.cs new file mode 100644 index 0000000..0c6ae7d --- /dev/null +++ b/kuzarin_maxim_lab_2/DAaS_FileConnections/Program.cs @@ -0,0 +1,29 @@ + +using PIHelperSh.RandomEx.Extentions; + +string inputPath = Environment.GetEnvironmentVariable("INPUT_PATH") ?? ".\\input1"; +string outputPath = Environment.GetEnvironmentVariable("OUTPUT_PATH") ?? ".\\output1"; + +if(!Directory.Exists(inputPath)) + Directory.CreateDirectory(inputPath); + +if(!Directory.Exists(outputPath)) + Directory.CreateDirectory(outputPath); + +var rnd = new Random(); + +for (int i = 0; i < rnd.Next(1000); i++) +{ + using var writer = new StreamWriter(Path.Combine(inputPath, $"{rnd.NextString(10)}.txt"), false); + + for (int j = 0; j < rnd.Next(1000); j++) + + { + writer.WriteLine(rnd.Next()); + } + writer.Close(); +} + + + + diff --git a/kuzarin_maxim_lab_2/FirstApplication/Dockerfile b/kuzarin_maxim_lab_2/FirstApplication/Dockerfile new file mode 100644 index 0000000..1fc32ba --- /dev/null +++ b/kuzarin_maxim_lab_2/FirstApplication/Dockerfile @@ -0,0 +1,35 @@ +# Это базовый образ для сборки. +FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base +# Указываем рабочий каталог для следующих комманд +WORKDIR /app + +# Проект нужно сначала собрать, поэтому берём sdk +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +# Это пременная. Будем собирать в режиме Relece. +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +# Копируем из папки хоста в контейнер +COPY ["FirstApplication.csproj", "FirstApplication/"] +# Выполняем комманду для загрузки всех нужных зависимостей +RUN dotnet restore "FirstApplication/FirstApplication.csproj" +# Назначаем новую базовую папку +WORKDIR "/src/FirstApplication" +# Копируем всё в папку для сборки +COPY . . +# Выполняем сборку проекта +RUN dotnet build "FirstApplication.csproj" -c $BUILD_CONFIGURATION -o /app/build + +# В этот этап попадает всё, что было в publish +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +# Публикуем всё в папку /app/publish +RUN dotnet publish "FirstApplication.csproj" -c $BUILD_CONFIGURATION -o /app/publish --self-contained false --no-restore + +# Берём тот образ, что определили в первой строке +FROM base AS final +# Указываем рабочую директорию +WORKDIR /app +# Из опубликованного блока берём то, что опубликовано и закидывае в /app +COPY --from=publish /app/publish . +# Указываем комманду запуска приложения (когда контейнер запустится, то начнёт с этого) +ENTRYPOINT ["dotnet", "FirstApplication.dll"] \ No newline at end of file diff --git a/kuzarin_maxim_lab_2/FirstApplication/FirstApplication.csproj b/kuzarin_maxim_lab_2/FirstApplication/FirstApplication.csproj new file mode 100644 index 0000000..df30bfa --- /dev/null +++ b/kuzarin_maxim_lab_2/FirstApplication/FirstApplication.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + Linux + + + + + + + diff --git a/kuzarin_maxim_lab_2/FirstApplication/Program.cs b/kuzarin_maxim_lab_2/FirstApplication/Program.cs new file mode 100644 index 0000000..25ce634 --- /dev/null +++ b/kuzarin_maxim_lab_2/FirstApplication/Program.cs @@ -0,0 +1,17 @@ +Console.WriteLine("Запущен первый сервис"); +string inputPath = Environment.GetEnvironmentVariable("INPUT_PATH") ?? "./input1"; +string outputPath = Environment.GetEnvironmentVariable("OUTPUT_PATH") ?? "./output1"; + +if (!Directory.Exists(inputPath)) + Directory.CreateDirectory(inputPath); + +if (!Directory.Exists(outputPath)) + Directory.CreateDirectory(outputPath); + +var file = new DirectoryInfo(inputPath).EnumerateFiles().Aggregate((x, y) => x.Length > y.Length ? x : y); + +var outputFilePath = Path.Combine(outputPath, "data.txt"); + +if(File.Exists(outputFilePath)) + File.Delete(outputFilePath); +File.Move(file.FullName, Path.Combine(outputPath, "data.txt")); diff --git a/kuzarin_maxim_lab_2/FirstApplication/Properties/launchSettings.json b/kuzarin_maxim_lab_2/FirstApplication/Properties/launchSettings.json new file mode 100644 index 0000000..b93d72a --- /dev/null +++ b/kuzarin_maxim_lab_2/FirstApplication/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "FirstApplication": { + "commandName": "Project" + }, + "Container (Dockerfile)": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/kuzarin_maxim_lab_2/README.md b/kuzarin_maxim_lab_2/README.md new file mode 100644 index 0000000..911bbb2 --- /dev/null +++ b/kuzarin_maxim_lab_2/README.md @@ -0,0 +1,25 @@ +# Лабораторная работа 2 +Данная работа посвящена теме создания контейнеров из исходного кода посредства dockerfile, а так же взаимодействию сервисов через общие папки +## Описание +Был варана следующая комбинация вариантов: + - Первое приложение - 0-ой + - Второе приложение - 1-ый +В результате, после запуска система изучит папку ./volumes/input, найдёт самый большой файл, а затем найдёт в нём самое большое число, выведя в директорию ./volumes/output файл с его квадратом. +Буфер же, по сути не имеет физического отображения на папку хоста. +## Запуск +Для запуска лабораторной работы необходимо иметь запущенный движок Docker на устройстве. +Необходимо перейти в папку, где располагается данный файл. Далее открыть терминал и ввести команду: +``` +docker compose up --build +``` +В данном случае флаг `--build` заставит систему в любом случае собрать образы из исходников (даже если они уже есть). +В результате, после сборки оба сервиса запустятся и выведут в консоль логи примерно следующего содержания: +## Описание dockerfile файла +Подробное описание дано в виде комментариев в самом файле первого сервиса. Так как для разработки использовался .net 8.0, команд довольно много. При этом, так как второй сервис написан на той же платформе, особенных отличий двух docekrfile-ов нет(кроме пути +## Описание compose файла +Благодаря директиве `depends_on` в compose файле второй сервис будет ждать, пока не будет поднят первый сервис, и только потом начнёт подниматься. +Директива `build` позволяет использовать в compose не уже готовый образ, а тот, что будет собран непосредственно в момент запуска(если он уже существует и нет флага силовой сборки, будет использоваться существующий образ) +Область volumes позволяет создать буферную область. Эту папку можно монтировать как результирующую для первого сервиса и исходную - для второго +## Видеодемонстрация +Был записан видеоролик, демонстрирующий процесс запуска и работы сервисов. Он расположен по [адресу](https://drive.google.com/file/d/1sACiKx3_HRApa89a7LZFAZV05o7POhq6/view?usp=sharing) + diff --git a/kuzarin_maxim_lab_2/SecondApplication/Dockerfile b/kuzarin_maxim_lab_2/SecondApplication/Dockerfile new file mode 100644 index 0000000..ab41eb4 --- /dev/null +++ b/kuzarin_maxim_lab_2/SecondApplication/Dockerfile @@ -0,0 +1,20 @@ +FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["SecondApplication.csproj", "SecondApplication/"] +RUN dotnet restore "./SecondApplication/SecondApplication.csproj" +WORKDIR "/src/SecondApplication" +COPY . . +RUN dotnet build "SecondApplication.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "SecondApplication.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "SecondApplication.dll"] \ No newline at end of file diff --git a/kuzarin_maxim_lab_2/SecondApplication/Program.cs b/kuzarin_maxim_lab_2/SecondApplication/Program.cs new file mode 100644 index 0000000..88f37a1 --- /dev/null +++ b/kuzarin_maxim_lab_2/SecondApplication/Program.cs @@ -0,0 +1,31 @@ +Console.WriteLine("Запущен второй сервис"); +string inputPath = Environment.GetEnvironmentVariable("INPUT_PATH") ?? ".\\input2"; +string outputPath = Environment.GetEnvironmentVariable("OUTPUT_PATH") ?? ".\\output2"; + +if (!Directory.Exists(outputPath)) + Directory.CreateDirectory(outputPath); + +var inputFilePath = Path.Combine(inputPath, "data.txt"); +var outputFilePath = Path.Combine(outputPath, "result.txt"); + +if (!File.Exists(inputFilePath)) +{ + Console.WriteLine($"Нет исходного файла {inputFilePath}"); + return; +} + +using var reader = new StreamReader(inputFilePath); + +long maxNumber = 0; + +while (true) +{ + var str = reader.ReadLine(); + if (str == null) break; + + if (long.TryParse(str, out var number) && number > maxNumber) + maxNumber = number; +} + +File.WriteAllText(outputFilePath, (maxNumber * maxNumber).ToString()); +Console.WriteLine($"Результат выполнения: {maxNumber * maxNumber}"); \ No newline at end of file diff --git a/kuzarin_maxim_lab_2/SecondApplication/Properties/launchSettings.json b/kuzarin_maxim_lab_2/SecondApplication/Properties/launchSettings.json new file mode 100644 index 0000000..2cc2f4d --- /dev/null +++ b/kuzarin_maxim_lab_2/SecondApplication/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "SecondApplication": { + "commandName": "Project" + }, + "Container (Dockerfile)": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/kuzarin_maxim_lab_2/SecondApplication/SecondApplication.csproj b/kuzarin_maxim_lab_2/SecondApplication/SecondApplication.csproj new file mode 100644 index 0000000..df30bfa --- /dev/null +++ b/kuzarin_maxim_lab_2/SecondApplication/SecondApplication.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + Linux + + + + + + + diff --git a/kuzarin_maxim_lab_2/docker-compose.yml b/kuzarin_maxim_lab_2/docker-compose.yml new file mode 100644 index 0000000..628de3d --- /dev/null +++ b/kuzarin_maxim_lab_2/docker-compose.yml @@ -0,0 +1,22 @@ +services: + first: + build: ./FirstApplication/ + volumes: + - ./volumes/input:/var/data + - buffer:/var/result + environment: + INPUT_PATH: "/var/data" + OUTPUT_PATH: "/var/result" + + second: + build: ./SecondApplication/ + depends_on: + - first + volumes: + - buffer:/var/data + - ./volumes/output:/var/result + environment: + INPUT_PATH: "/var/data" + OUTPUT_PATH: "/var/result" +volumes: + buffer: \ No newline at end of file