diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b419a5f6..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2 -jobs: - build: - working_directory: /temp - docker: - - image: microsoft/dotnet:sdk - environment: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - steps: - - checkout - - run: dotnet restore - - run: dotnet build \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..9671f845 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,99 @@ +name: CI + +on: + push: + branches: + - master + - ci-gh-action-migration # For testing GitHub Action Workflows + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + env: + DOTNET_NO_GLOBAL: 'true' # Ignore global.json + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: display git info about the checkout stuff + run: git rev-parse --abbrev-ref HEAD + + - name: Set up JDK 15 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '15' + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + 5.0.200 + + - name: Install .NET tools + run: | + dotnet tool install -g dotnet-sonarscanner -v:m + + - name: Add .NET tools to PATH + run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.14 + with: + versionSpec: '5.x' + + - name: Execute GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.14 + + - name: Restore dependencies + run: dotnet restore --disable-parallel --ignore-failed-sources + + - name: Run code formatting check + run: dotnet format --check + + - name: Patch csproj files with version + run: | + find . -name '*.csproj' -exec sed -i 's/.*<\/Version>/${{ steps.gitversion.outputs.NuGetVersion }}<\/Version>/g' {} + + + - name: SonarScanner begin + run: | + dotnet sonarscanner begin \ + /d:sonar.host.url=https://sonarcloud.io \ + /d:sonar.login=$SONAR_TOKEN \ + /k:mariotoffia_FluentDocker \ + /o:mariotoffia \ + /v:"${{ steps.gitversion.outputs.NuGetVersion }}" \ + /d:sonar.cs.opencover.reportsPaths="./output/coverage.opencover.xml" \ + /d:sonar.coverage.exclusions="**Tests*.cs" + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Build + run: dotnet build FluentDocker.sln --configuration Release --no-restore --verbosity minimal /p:Version=${{ steps.gitversion.outputs.NuGetVersion }} + + - name: Test + run: dotnet test --settings coverletArgs.runsettings --filter TestCategory=CI -f netcoreapp3.1 + + - name: SonarScanner end + run: dotnet sonarscanner end /d:sonar.login=$SONAR_TOKEN + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Package NuGet + run: dotnet pack FluentDocker.sln --configuration Release -o output /p:Version=${{ steps.gitversion.outputs.NuGetVersion }} + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: NuGet Packages + path: ./output/*.nupkg + + # Deployment step conditioned to run only on master branch + - name: Deploy to NuGet + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + run: echo "Deploying to NuGet..." +#run: dotnet nuget push ./output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json \ No newline at end of file diff --git a/Ductus.FluentDocker.MsTest/Ductus.FluentDocker.MsTest.csproj b/Ductus.FluentDocker.MsTest/Ductus.FluentDocker.MsTest.csproj index e56df543..0ebc676a 100644 --- a/Ductus.FluentDocker.MsTest/Ductus.FluentDocker.MsTest.csproj +++ b/Ductus.FluentDocker.MsTest/Ductus.FluentDocker.MsTest.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461 + net6.0 1.0.0 1.0.0.0 1.0.0.0 diff --git a/Ductus.FluentDocker.Tests/Ductus.FluentDocker.Tests.csproj b/Ductus.FluentDocker.Tests/Ductus.FluentDocker.Tests.csproj index 8fc465c7..745c2dbf 100644 --- a/Ductus.FluentDocker.Tests/Ductus.FluentDocker.Tests.csproj +++ b/Ductus.FluentDocker.Tests/Ductus.FluentDocker.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1;net5.0;net461 + net6.0 @@ -10,7 +10,7 @@ - + diff --git a/Ductus.FluentDocker.Tests/FluentApiTests/FluentContainerBasicTests.cs b/Ductus.FluentDocker.Tests/FluentApiTests/FluentContainerBasicTests.cs index 5aae447e..cf7d0964 100644 --- a/Ductus.FluentDocker.Tests/FluentApiTests/FluentContainerBasicTests.cs +++ b/Ductus.FluentDocker.Tests/FluentApiTests/FluentContainerBasicTests.cs @@ -6,7 +6,7 @@ using Ductus.FluentDocker.Model.Builders; using Ductus.FluentDocker.Model.Common; using Ductus.FluentDocker.Model.Containers; -using Ductus.FluentDocker.Services; +using Ductus.FluentDocker.Services; using Ductus.FluentDocker.Services.Extensions; using Ductus.FluentDocker.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/Ductus.FluentDocker.XUnit/Ductus.FluentDocker.XUnit.csproj b/Ductus.FluentDocker.XUnit/Ductus.FluentDocker.XUnit.csproj index b45576e6..5e72dca2 100644 --- a/Ductus.FluentDocker.XUnit/Ductus.FluentDocker.XUnit.csproj +++ b/Ductus.FluentDocker.XUnit/Ductus.FluentDocker.XUnit.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net461 + net6.0 1.0.0 1.0.0.0 1.0.0.0 diff --git a/Ductus.FluentDocker/Commands/Images.cs b/Ductus.FluentDocker/Commands/Images.cs new file mode 100644 index 00000000..c6033265 --- /dev/null +++ b/Ductus.FluentDocker/Commands/Images.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using Ductus.FluentDocker.Executors; +using Ductus.FluentDocker.Executors.Parsers; +using Ductus.FluentDocker.Extensions; +using Ductus.FluentDocker.Model.Common; +using Ductus.FluentDocker.Model.Containers; +using Ductus.FluentDocker.Model.Images; + +namespace Ductus.FluentDocker.Commands +{ + public static class Images + { + /// + /// List images. TODO: Not implemented - DO NOT USE THIS METHOD!! + /// + public static CommandResponse> Rm( + this DockerUri host, + ICertificatePaths certificates = null, + bool force = false, bool prune = false, + params string[] imageId) + { + + // TODO: Need to implement executor properly. + var options = ""; + + if (!prune) { + options = "--no-prune"; + } + + if (force) { + options += "--force"; + } + + return + new ProcessExecutor>( + "docker".ResolveBinary(), + $"{host.RenderBaseArgs(certificates)} images rm {options} {string.Join(" ", imageId)}").Execute(); + } + + } +} \ No newline at end of file diff --git a/Ductus.FluentDocker/Ductus.FluentDocker.csproj b/Ductus.FluentDocker/Ductus.FluentDocker.csproj index fb370007..eb2bfe27 100644 --- a/Ductus.FluentDocker/Ductus.FluentDocker.csproj +++ b/Ductus.FluentDocker/Ductus.FluentDocker.csproj @@ -1,6 +1,6 @@ - netstandard2.0;netstandard2.1;net461 + net6.0 1.0.0 1.0.0.0 1.0.0.0 diff --git a/Ductus.FluentDocker/Executors/Parsers/ImageRmResponseParser.cs b/Ductus.FluentDocker/Executors/Parsers/ImageRmResponseParser.cs new file mode 100644 index 00000000..44e65f81 --- /dev/null +++ b/Ductus.FluentDocker/Executors/Parsers/ImageRmResponseParser.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using Ductus.FluentDocker.Model.Containers; +using Ductus.FluentDocker.Model.Images; +using Ductus.FluentDocker.Extensions; +using System; + +namespace Ductus.FluentDocker.Executors.Parsers +{ + public sealed class ImageRmResponseParser : IProcessResponseParser> + { + public CommandResponse> Response { get; private set; } + public IProcessResponse> Process(ProcessExecutionResult response) + { + if (response.ExitCode != 0) + { + Response = response.ToErrorResponse((IList)new List()); + return this; + } + + var list = new List(); + foreach (var row in response.StdOutAsArray) + { + var items = row.Split(new string[]{": "},1,StringSplitOptions.RemoveEmptyEntries); + if (items.Length != 2) + { + continue; + } + + + list.Add(new DockerRmImageRowResponse + { + Id = items[1].Contains("sha") ? items[1].ToPlainId() : items[1], + Command = items[0] + }); + } + + Response = response.ToResponse(true, string.Empty, (IList)list); + return this; + } + } +} diff --git a/Ductus.FluentDocker/Model/Images/DockerImageRmRowResponse.cs b/Ductus.FluentDocker/Model/Images/DockerImageRmRowResponse.cs new file mode 100644 index 00000000..bcf211ec --- /dev/null +++ b/Ductus.FluentDocker/Model/Images/DockerImageRmRowResponse.cs @@ -0,0 +1,8 @@ +namespace Ductus.FluentDocker.Model.Images +{ + public sealed class DockerRmImageRowResponse + { + public string Id { get; set; } + public string Command { get; set; } + } +} diff --git a/Examples/.vscode/launch.json b/Examples/.vscode/launch.json deleted file mode 100644 index 5b07fb86..00000000 --- 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 5402d43b..00000000 --- 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 31c32bd3..00000000 --- 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 9d497a95..00000000 --- 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 9a3c47fd..00000000 --- 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 07d06b52..00000000 --- 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 eaad0ed8..00000000 --- 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 93503e3a..00000000 --- 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 b47fb4a2..00000000 --- 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 fb5ef0ac..00000000 --- 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 5da6f9ed..00000000 --- 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 e2228342..00000000 --- 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 3c92f496..00000000 --- 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 3aea6ba8..00000000 --- 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 3bdfb224..00000000 --- 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 3fdaff39..00000000 --- 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 fb5ef0ac..00000000 --- a/Examples/Simple/Simple.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - - - - diff --git a/Examples/global.json b/Examples/global.json deleted file mode 100644 index 13b8b145..00000000 --- a/Examples/global.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/global", - "sdk": { - "version": "5.0.200", - "allowPrerelease": false, - "rollForward": "latestMinor" - } -} diff --git a/FluentDocker.sln b/FluentDocker.sln index c2bac81d..567f3759 100644 --- a/FluentDocker.sln +++ b/FluentDocker.sln @@ -10,7 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution appveyor.yml = appveyor.yml coverletArgs.runsettings = coverletArgs.runsettings GitVersion.yml = GitVersion.yml - global.json = global.json docs\index.md = docs\index.md NuGet.config = NuGet.config README.md = README.md diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 616ae90d..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,66 +0,0 @@ -skip_non_tags: false -#test: off -image: Visual Studio 2019 -configuration: Release - -# Only build when [release] is in the commit title -#only_commits: -# message: /\[release\]/ - -skip_commits: - files: - - Examples/**/* - - '**/*.md' - -dotnet_csproj: - patch: true - file: '**\*.csproj' - version: '{version}' - package_version: '{version}' - assembly_version: '{version}' - file_version: '{version}' - informational_version: '{version}' - -init: - - set PATH=C:\Program Files\Java\jdk15\bin;%PATH% - - set JAVA_HOME_11_X64=C:\Program Files\Java\jdk15 - - set JAVA_HOME=C:\Program Files\Java\jdk15 - -install: - - ps: Switch-DockerLinux - - ps: dotnet tool install -g GitVersion.Tool - - ps: dotnet tool install -g dotnet-format - - ps: dotnet tool install -g dotnet-sonarscanner -v:m - -before_build: - - nuget restore - # - ps: dotnet format --check --dry-run - - ps: dotnet gitversion /l console /output buildserver - - ps: dotnet sonarscanner begin /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=e220dd372506f00fe34923f011ea45f8568e9bcc /k:mariotoffia_FluentDocker /o:mariotoffia /v:"$env:APPVEYOR_BUILD_NUMBER" /d:sonar.cs.opencover.reportsPaths="./output/coverage.opencover.xml" /d:sonar.coverage.exclusions="**Tests*.cs" - - ps: $env:good_to_deploy="true" - - ps: if (Test-Path env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) {echo "Not going to deploy because pull request."} - - ps: if (Test-Path env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) {$env:good_to_deploy="false"} - - echo good_to_deploy=%good_to_deploy% - -build: - project: FluentDocker.sln - publish_nuget: true - verbosity: minimal - -test_script: - - ps: dotnet test --settings coverletArgs.runsettings --filter TestCategory=CI -f netcoreapp3.1 - -after_test: - - ps: dotnet sonarscanner end /d:sonar.login=e220dd372506f00fe34923f011ea45f8568e9bcc - -artifacts: - - path: '.\**\Release\*.nupkg' - name: NuGet Packages - -deploy: - - provider: NuGet - on: - branch: master - good_to_deploy: true - api_key: - secure: JltY4YIjjAWA5cjaWbc9b2LWTE41Wthz886xZt3zCXz3PZWF/JQ286freKBTNqnM