From bb2205396f01bea2f5627d287aa2b5ea48eb7796 Mon Sep 17 00:00:00 2001 From: Mario Toffia Date: Sun, 6 Oct 2024 15:59:41 +0200 Subject: [PATCH] removed example solution --- Examples/.vscode/launch.json | 26 ---- Examples/.vscode/settings.json | 6 - Examples/.vscode/tasks.json | 24 ---- .../DockerInDockerLinux.csproj | 9 -- Examples/DockerInDockerLinux/Dockerfile | 12 -- Examples/DockerInDockerLinux/Program.cs | 22 --- Examples/DockerInDockerLinux/README.md | 12 -- Examples/DockerInDockerLinux/build.sh | 4 - Examples/DockerInDockerLinux/run.sh | 3 - Examples/EventDriven/EventDriven.csproj | 11 -- Examples/EventDriven/Program.cs | 58 -------- Examples/EventDriven/README.md | 16 --- Examples/Examples.sln | 62 --------- Examples/README.md | 5 - Examples/Simple/Program.cs | 125 ------------------ Examples/Simple/README.md | 3 - Examples/Simple/Simple.csproj | 11 -- 17 files changed, 409 deletions(-) delete mode 100644 Examples/.vscode/launch.json delete mode 100644 Examples/.vscode/settings.json delete mode 100644 Examples/.vscode/tasks.json delete mode 100644 Examples/DockerInDockerLinux/DockerInDockerLinux.csproj delete mode 100644 Examples/DockerInDockerLinux/Dockerfile delete mode 100644 Examples/DockerInDockerLinux/Program.cs delete mode 100644 Examples/DockerInDockerLinux/README.md delete mode 100755 Examples/DockerInDockerLinux/build.sh delete mode 100755 Examples/DockerInDockerLinux/run.sh delete mode 100644 Examples/EventDriven/EventDriven.csproj delete mode 100644 Examples/EventDriven/Program.cs delete mode 100644 Examples/EventDriven/README.md delete mode 100644 Examples/Examples.sln delete mode 100644 Examples/README.md delete mode 100644 Examples/Simple/Program.cs delete mode 100644 Examples/Simple/README.md delete mode 100644 Examples/Simple/Simple.csproj diff --git a/Examples/.vscode/launch.json b/Examples/.vscode/launch.json deleted file mode 100644 index 5b07fb8..0000000 --- a/Examples/.vscode/launch.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/Simple/bin/Debug/netcoreapp3.1/Simple.dll", - "args": [], - "cwd": "${workspaceFolder}/Simple", - // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console - "console": "internalConsole", - "stopAtEntry": false - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach" - } - ] -} \ No newline at end of file diff --git a/Examples/.vscode/settings.json b/Examples/.vscode/settings.json deleted file mode 100644 index 5402d43..0000000 --- a/Examples/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cSpell.words": [ - "Ductus", - "mysecretpassword" - ] -} \ No newline at end of file diff --git a/Examples/.vscode/tasks.json b/Examples/.vscode/tasks.json deleted file mode 100644 index 31c32bd..0000000 --- a/Examples/.vscode/tasks.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "shell", - "args": [ - "build", - // Ask dotnet build to generate full paths for file names. - "/property:GenerateFullPaths=true", - // Do not generate summary otherwise it leads to duplicate errors in Problems panel - "/consoleloggerparameters:NoSummary" - ], - "group": "build", - "presentation": { - "reveal": "silent" - }, - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file diff --git a/Examples/DockerInDockerLinux/DockerInDockerLinux.csproj b/Examples/DockerInDockerLinux/DockerInDockerLinux.csproj deleted file mode 100644 index 9d497a9..0000000 --- a/Examples/DockerInDockerLinux/DockerInDockerLinux.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - Exe - netcoreapp3.1 - - - - - \ No newline at end of file diff --git a/Examples/DockerInDockerLinux/Dockerfile b/Examples/DockerInDockerLinux/Dockerfile deleted file mode 100644 index 9a3c47f..0000000 --- a/Examples/DockerInDockerLinux/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:3.1 - -WORKDIR /App -COPY bin/Debug/netcoreapp3.1 . - -RUN apt-get -qq update && apt-get -qq install wget -RUN wget --quiet https://download.docker.com/linux/static/stable/x86_64/docker-20.10.8.tgz && \ - tar -xzf docker-20.10.8.tgz - -RUN cp docker/* /usr/bin/ && rm -rf docker - -ENTRYPOINT ["dotnet", "DockerInDockerLinux.dll"] \ No newline at end of file diff --git a/Examples/DockerInDockerLinux/Program.cs b/Examples/DockerInDockerLinux/Program.cs deleted file mode 100644 index 07d06b5..0000000 --- a/Examples/DockerInDockerLinux/Program.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Linq; -using Ductus.FluentDocker.Commands; -using Ductus.FluentDocker.Services; - -namespace DockerInDockerLinux -{ - class Program - { - static void Main(string[] args) - { - var hosts = new Hosts().Discover(); - - var docker = hosts.FirstOrDefault(x => x.IsNative) ?? hosts.FirstOrDefault(x => x.Name == "default"); - Console.WriteLine($"Docker host: {docker?.Host.Host}, {docker?.Host.AbsolutePath}, {docker?.Host.AbsoluteUri}"); - - var containers = docker?.GetContainers(); - Console.WriteLine(docker?.Host.Host); - Console.WriteLine($"Number of containers: {containers?.Count}"); - } - } -} diff --git a/Examples/DockerInDockerLinux/README.md b/Examples/DockerInDockerLinux/README.md deleted file mode 100644 index eaad0ed..0000000 --- a/Examples/DockerInDockerLinux/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# DockerInDockerLinux - -This is a simple example of how to run Docker commands in parent, host, environment within a Docker container. Since the docker container do mount the host docker socket on the default linux socket, _FluentDocker_ will execute the commands as it would if it was running on the host. - -The example is showing two steps necessary to achieve this. - -1. Make sure that the docker client binary is installed and on the containers environment PATH (see _build.sh_). -2. Mount the docker socket properly when running the container (_see run.sh_) - -This reflects [Issue #199](https://github.com/mariotoffia/FluentDocker/issues/199) for _Linux_ and [Issue #99](https://github.com/mariotoffia/FluentDocker/issues/99) for _Windows_. - -When running the container it should _at least_ output one container (this _docker-in-docker_ container). \ No newline at end of file diff --git a/Examples/DockerInDockerLinux/build.sh b/Examples/DockerInDockerLinux/build.sh deleted file mode 100755 index 93503e3..0000000 --- a/Examples/DockerInDockerLinux/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -## Builds the docker image -dotnet build -docker build -t docker-in-docker -f Dockerfile . diff --git a/Examples/DockerInDockerLinux/run.sh b/Examples/DockerInDockerLinux/run.sh deleted file mode 100755 index b47fb4a..0000000 --- a/Examples/DockerInDockerLinux/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -## Will execute the built docker container -docker run --rm -v /var/run/docker.sock:/var/run/docker.sock docker-in-docker \ No newline at end of file diff --git a/Examples/EventDriven/EventDriven.csproj b/Examples/EventDriven/EventDriven.csproj deleted file mode 100644 index fb5ef0a..0000000 --- a/Examples/EventDriven/EventDriven.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - - - - diff --git a/Examples/EventDriven/Program.cs b/Examples/EventDriven/Program.cs deleted file mode 100644 index 5da6f9e..0000000 --- a/Examples/EventDriven/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using Ductus.FluentDocker; -using Ductus.FluentDocker.Builders; -using Ductus.FluentDocker.Extensions; -using Ductus.FluentDocker.Model.Events; -using Ductus.FluentDocker.Services; -using Ductus.FluentDocker.Services.Extensions; - -namespace EventDriven -{ - class Program - { - static void Main(string[] args) - { - var hosts = new Hosts().Discover(); - Console.WriteLine($"Number of hosts:{hosts.Count}"); - - foreach (var host in hosts) - { - Console.WriteLine($"{host.Host} {host.Name} {host.State}"); - } - - Console.WriteLine("Spinning up a postgres and wait for ready state..."); - using (var events = Fd.Native().Events()) - { - using ( - var container = - new Builder().UseContainer() - .UseImage("postgres:9.6-alpine") - .ExposePort(5432) - .WithEnvironment("POSTGRES_PASSWORD=mysecretpassword") - .WaitForPort("5432/tcp", 30000) - .Build() - .Start()) - { - var config = container.GetConfiguration(true); - Console.WriteLine(ServiceRunningState.Running == config.State.ToServiceState() - ? "Service is running" - : "Failed to start nginx instance..."); - - FdEvent evt; - var list = new List(); - while ((evt = events.TryRead(5000)) != null) - { - list.Add(evt); - } - - Console.WriteLine("Events:"); - foreach (var e in list) - { - Console.WriteLine(e); - } - } - } - } - } -} diff --git a/Examples/EventDriven/README.md b/Examples/EventDriven/README.md deleted file mode 100644 index e222834..0000000 --- a/Examples/EventDriven/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# EventDriven - -This project will show how to subscribe to events on a certain docker _daemon_ and what they are for firing up a single container. - -Example Run: - -```bash -Number of hosts:1 -unix:///var/run/docker.sock native Running -Spinning up a postgres and wait for ready state... -Service is running -Events: -Ductus.FluentDocker.Model.Events.ContainerCreateEvent -Ductus.FluentDocker.Model.Events.NetworkConnectEvent -Ductus.FluentDocker.Model.Events.ContainerStartEvent -``` \ No newline at end of file diff --git a/Examples/Examples.sln b/Examples/Examples.sln deleted file mode 100644 index 3c92f49..0000000 --- a/Examples/Examples.sln +++ /dev/null @@ -1,62 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 -MinimumVisualStudioVersion = 15.0.26124.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DockerInDockerLinux", "DockerInDockerLinux\DockerInDockerLinux.csproj", "{956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventDriven", "EventDriven\EventDriven.csproj", "{75D101EB-5CE3-457E-8843-76898CB5513B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple", "Simple\Simple.csproj", "{25359F72-CCB4-4373-9857-D0AC45F8510F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Debug|Any CPU.Build.0 = Debug|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Debug|x64.ActiveCfg = Debug|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Debug|x64.Build.0 = Debug|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Debug|x86.ActiveCfg = Debug|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Debug|x86.Build.0 = Debug|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Release|Any CPU.ActiveCfg = Release|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Release|Any CPU.Build.0 = Release|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Release|x64.ActiveCfg = Release|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Release|x64.Build.0 = Release|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Release|x86.ActiveCfg = Release|Any CPU - {956E68C4-C0DA-4EEB-BD4F-B19F56A1AC24}.Release|x86.Build.0 = Release|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Debug|x64.ActiveCfg = Debug|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Debug|x64.Build.0 = Debug|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Debug|x86.ActiveCfg = Debug|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Debug|x86.Build.0 = Debug|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Release|Any CPU.Build.0 = Release|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Release|x64.ActiveCfg = Release|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Release|x64.Build.0 = Release|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Release|x86.ActiveCfg = Release|Any CPU - {75D101EB-5CE3-457E-8843-76898CB5513B}.Release|x86.Build.0 = Release|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Debug|x64.ActiveCfg = Debug|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Debug|x64.Build.0 = Debug|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Debug|x86.ActiveCfg = Debug|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Debug|x86.Build.0 = Debug|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Release|Any CPU.Build.0 = Release|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Release|x64.ActiveCfg = Release|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Release|x64.Build.0 = Release|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Release|x86.ActiveCfg = Release|Any CPU - {25359F72-CCB4-4373-9857-D0AC45F8510F}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/Examples/README.md b/Examples/README.md deleted file mode 100644 index 3aea6ba..0000000 --- a/Examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples - -In this folder, there are samples of the different features of the library that is not captured in a unit test or is more clean to do as a sample. - -👀 The Test project sample will also be converted into a sample and the _Test_ folder will be removed from the project. \ No newline at end of file diff --git a/Examples/Simple/Program.cs b/Examples/Simple/Program.cs deleted file mode 100644 index 3bdfb22..0000000 --- a/Examples/Simple/Program.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Linq; -using System.Diagnostics; -using Ductus.FluentDocker.Model.Containers; -using Ductus.FluentDocker.Builders; -using Ductus.FluentDocker.Extensions; -using Ductus.FluentDocker.Services; - -namespace Simple -{ - class Program - { - static void RunSingleContainerFluentAPI() - { - using ( - var container = - new Builder().UseContainer() - .UseImage("postgres:9.6-alpine") - .ExposePort(5432) - .WithEnvironment("POSTGRES_PASSWORD=mysecretpassword") - .WaitForPort("5432/tcp", 30000) - .Build() - .Start()) - { - - var config = container.GetConfiguration(true); - var running = ServiceRunningState.Running == config.State.ToServiceState(); - - Console.WriteLine(running ? "Service is running" : "Failed to start nginx instance..."); - - } - } - - static void PerformanceSingleContainer() - { - - Stopwatch stopwatch = new Stopwatch(); - - stopwatch.Start(); - var hosts = new Hosts().Discover(); - var host = hosts.FirstOrDefault(x => x.IsNative) ?? hosts.FirstOrDefault(x => x.Name == "default"); - - Console.WriteLine("Hosts discovered in {0} s", TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds); - - var _container = host.Create("nginx:alpine", - prms: new ContainerCreateParams - { - Name = "test", - Network = "host", - PortMappings = new string[] { "9111:80", "9112:443" }, - Volumes = new string[] { "/data/log:/var/log:rw" }, - RestartPolicy = RestartPolicy.Always - }); - - Console.WriteLine("Create container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds); - - try - { - stopwatch.Restart(); - _container.Start(); - - Console.WriteLine("Start container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds); - } - finally - { - - stopwatch.Restart(); - _container.Dispose(); - Console.WriteLine("Dispose container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds); - - stopwatch.Stop(); - - } - - } - - static void PerformanceSingleContainerFluentAPI() - { - - Stopwatch stopwatch = new Stopwatch(); - - stopwatch.Start(); - var container = new Builder().UseContainer() - .UseImage("postgres:9.6-alpine") - .ExposePort(5432) - .WithEnvironment("POSTGRES_PASSWORD=mysecretpassword") - .WaitForPort("5432/tcp", 30000) - .Build(); - - Console.WriteLine("Build container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds); - - try - { - stopwatch.Restart(); - container.Start(); - Console.WriteLine("Start container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds); - - stopwatch.Restart(); - var config = container.GetConfiguration(true); - Console.WriteLine("Get configuration: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds); - - var running = ServiceRunningState.Running == config.State.ToServiceState(); - Console.WriteLine(running ? "Service is running" : "Failed to start nginx instance..."); - - - } - finally - { - - stopwatch.Restart(); - container.Dispose(); - Console.WriteLine("Dispose container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds); - - stopwatch.Stop(); - } - } - - static void Main(string[] args) - { - //RunSingleContainerFluentAPI(); - //PerformanceSingleContainer(); - //PerformanceSingleContainerFluentAPI(); - } - } -} diff --git a/Examples/Simple/README.md b/Examples/Simple/README.md deleted file mode 100644 index 3fdaff3..0000000 --- a/Examples/Simple/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Simple - -Simple test project to demonstrate how to use _FluentDocker_ in various ways. \ No newline at end of file diff --git a/Examples/Simple/Simple.csproj b/Examples/Simple/Simple.csproj deleted file mode 100644 index fb5ef0a..0000000 --- a/Examples/Simple/Simple.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - - - -