You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2019/05/07 15:21:40 UTC

[ignite] 32/41: GG-17383 [IGNITE-11805] .NET: Add runnable .NET Core assembly, add Dockerfile (#6501)

This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch gg-18540
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 98aec2d069d3b5a8e52ba7a0c39268fa2b813cdf
Author: Aleksandr Shapkin <14...@users.noreply.github.com>
AuthorDate: Tue Apr 30 11:34:23 2019 +0300

    GG-17383 [IGNITE-11805] .NET: Add runnable .NET Core assembly, add Dockerfile (#6501)
    
    (cherry picked from commit 3963797cd477b67f5886e177f4af347fe77124fc)
    (cherry picked from commit aeb631ab53add1dec1d22d8f82345c8f70f244c6)
---
 docker/apache-ignite-net/Dockerfile                | 32 ++++++++++
 docker/apache-ignite-net/README.txt                | 23 +++++++
 .../platforms/dotnet/Apache.Ignite.DotNetCore.sln  |  6 ++
 .../Apache.Ignite/Apache.Ignite.DotNetCore.csproj  | 25 ++++++++
 .../dotnet/Apache.Ignite/Apache.Ignite.csproj      |  1 +
 .../platforms/dotnet/Apache.Ignite/ConsoleUtils.cs | 68 ++++++++++++++++++++
 .../dotnet/Apache.Ignite/IgniteCoreRunner.cs       | 74 ++++++++++++++++++++++
 .../platforms/dotnet/Apache.Ignite/IgniteRunner.cs | 37 +----------
 modules/platforms/dotnet/DEVNOTES.txt              |  1 +
 modules/platforms/dotnet/build.ps1                 | 29 ++++++++-
 10 files changed, 259 insertions(+), 37 deletions(-)

diff --git a/docker/apache-ignite-net/Dockerfile b/docker/apache-ignite-net/Dockerfile
new file mode 100644
index 0000000..3381b61
--- /dev/null
+++ b/docker/apache-ignite-net/Dockerfile
@@ -0,0 +1,32 @@
+#
+# Copyright 2019 GridGain Systems, Inc. and Contributors.
+# 
+# Licensed under the GridGain Community Edition License (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+#     https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Build runtime image
+FROM microsoft/dotnet:runtime
+
+## Workaround for apt/jre issues
+RUN mkdir -p /usr/share/man/man1
+RUN apt update && apt install apt-utils -y --no-install-recommends
+
+## Install JRE
+RUN apt update && apt install openjdk-8-jre-headless -y --no-install-recommends
+
+WORKDIR /app
+
+COPY libs ./libs
+COPY publish ./
+
+ENTRYPOINT ["dotnet", "Apache.Ignite.dll"]
diff --git a/docker/apache-ignite-net/README.txt b/docker/apache-ignite-net/README.txt
new file mode 100644
index 0000000..18dae09
--- /dev/null
+++ b/docker/apache-ignite-net/README.txt
@@ -0,0 +1,23 @@
+Apache Ignite .NET Docker module
+===========================
+Apache Ignite .NET Docker module provides Dockerfile and accompanying files for building docker image.
+
+
+Build image
+===========
+1) Build Apache Ignite.NET as described at modules/platforms/dotnet/DEVNOTES.txt
+
+2) Goto Apache Ignite's Docker module directory
+
+        cd modules/docker
+
+3) Copy Apache Ignite.NET's binaries to libs and publish folders
+
+        cp -r ../../modules/platforms/dotnet/bin/libs libs
+        cp -r ../../modules/platforms/dotnet/bin/netcoreapp2.0/publish/ publish
+
+4) Build docker image
+
+        docker build . -t apacheignite/ignite-net[:<version>]
+
+   Prepared image will be available issuing `docker images` command
diff --git a/modules/platforms/dotnet/Apache.Ignite.DotNetCore.sln b/modules/platforms/dotnet/Apache.Ignite.DotNetCore.sln
index ecd2840..3724eab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.DotNetCore.sln
+++ b/modules/platforms/dotnet/Apache.Ignite.DotNetCore.sln
@@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Ignite.Linq.DotNetCo
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apache.Ignite.Core.Tests.DotNetCore", "Apache.Ignite.Core.Tests.DotNetCore\Apache.Ignite.Core.Tests.DotNetCore.csproj", "{700215D4-60E8-4DB2-923F-D4F4D95CBD95}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.DotNetCore", "Apache.Ignite\Apache.Ignite.DotNetCore.csproj", "{A28AA3F7-BA2B-49C2-B5DA-02707D4470B1}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,10 @@ Global
 		{700215D4-60E8-4DB2-923F-D4F4D95CBD95}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{700215D4-60E8-4DB2-923F-D4F4D95CBD95}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{700215D4-60E8-4DB2-923F-D4F4D95CBD95}.Release|Any CPU.Build.0 = Release|Any CPU
+		{A28AA3F7-BA2B-49C2-B5DA-02707D4470B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{A28AA3F7-BA2B-49C2-B5DA-02707D4470B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{A28AA3F7-BA2B-49C2-B5DA-02707D4470B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{A28AA3F7-BA2B-49C2-B5DA-02707D4470B1}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.DotNetCore.csproj b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.DotNetCore.csproj
new file mode 100644
index 0000000..45a9196
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.DotNetCore.csproj
@@ -0,0 +1,25 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.0</TargetFramework>
+    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+    <AssemblyName>Apache.Ignite</AssemblyName>
+    <RootNamespace>Apache.Ignite</RootNamespace>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Compile Remove="Service\**" />
+    <EmbeddedResource Remove="Service\**" />
+    <None Remove="Service\**" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Compile Remove="IgniteRunner.cs" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Apache.Ignite.Core\Apache.Ignite.Core.DotNetCore.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
index 3e8f83e..97bafa5 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
@@ -47,6 +47,7 @@
     <Compile Include="Config\ArgsConfigurator.cs" />
     <Compile Include="Config\Configurator.cs" />
     <Compile Include="Config\ConfigValueParser.cs" />
+    <Compile Include="ConsoleUtils.cs" />
     <Compile Include="IgniteRunner.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Service\IgniteService.cs">
diff --git a/modules/platforms/dotnet/Apache.Ignite/ConsoleUtils.cs b/modules/platforms/dotnet/Apache.Ignite/ConsoleUtils.cs
new file mode 100644
index 0000000..117f17a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite/ConsoleUtils.cs
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2019 GridGain Systems, Inc. and Contributors.
+ * 
+ * Licensed under the GridGain Community Edition License (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite
+{
+    using System;
+
+    /// <summary>
+    /// Console utilities.
+    /// </summary>
+    internal static class ConsoleUtils
+    {
+        /// <summary>
+        /// Prints help.
+        /// </summary>
+        /// <param name="entryPoint">Application entry point.</param>
+        /// <param name="useServices">Indicates whether include service info in help or not.</param>
+        public static void PrintHelp(string entryPoint, bool useServices)
+        {
+            if (useServices)
+            {
+                Console.WriteLine("Usage: {0} [/install] [/uninstall] [-options]", entryPoint);
+                Console.WriteLine("");
+                Console.WriteLine("\t/install [-options]    installs Ignite Windows service with provided options.");
+                Console.WriteLine("\t/uninstall             uninstalls Ignite Windows service.");
+            }
+            else
+            {
+                Console.WriteLine("Usage: {0}  [-options]", entryPoint);
+            }
+            Console.WriteLine("");
+            Console.WriteLine("Options:");
+            Console.WriteLine("\t-IgniteHome            path to Ignite installation directory (if not provided IGNITE_HOME environment variable is used).");
+            Console.WriteLine("\t-ConfigSectionName     name of the IgniteConfigurationSection in app.config to use.");
+            Console.WriteLine("\t-ConfigFileName        path to the app.config file (if not provided Apache.Ignite.exe.config is used).");
+            Console.WriteLine("\t-springConfigUrl       path to Spring configuration file.");
+            Console.WriteLine("\t-jvmDll                path to JVM library jvm.dll (if not provided JAVA_HOME environment variable is used).");
+            Console.WriteLine("\t-jvmClasspath          classpath passed to JVM (enlist additional jar files here).");
+            Console.WriteLine("\t-suppressWarnings      whether to print warnings.");
+            Console.WriteLine("\t-J<javaOption>         JVM options passed to created JVM.");
+            Console.WriteLine("\t-assembly=userLib.dll  additional .NET assemblies to be loaded.");
+            Console.WriteLine("\t-jvmInitialMemoryMB    Initial Java heap size, in megabytes. Maps to -Xms Java parameter. Defaults to 512.");
+            Console.WriteLine("\t-jvmMaxMemoryMB        Maximum Java heap size, in megabytes. Maps to -Xmx Java parameter. Defaults to 1024.");
+            Console.WriteLine("");
+            Console.WriteLine("Examples:");
+            Console.WriteLine("\t{0} -J-Xms1024m -J-Xmx1024m -springConfigUrl=C:/woer/gg-test/my-test-gg-confignative.xml", entryPoint);
+            Console.WriteLine("\t{0} -IgniteHome=c:/apache-ignite -jvmClasspath=libs/myLib1.jar;libs/myLib2.jar", entryPoint);
+            Console.WriteLine("\t{0} -assembly=c:/myProject/libs/lib1.dll -assembly=c:/myProject/libs/lib2.dll", entryPoint);
+            Console.WriteLine("\t{0} -jvmInitialMemoryMB=1024 -jvmMaxMemoryMB=4096", entryPoint);
+            Console.WriteLine("");
+            Console.WriteLine("Note:");
+            Console.WriteLine("Command line settings have priority over Apache.Ignite.exe.config settings. JVM options and assemblies are concatenated; data from config file comes first, then data from command line.");
+        }
+    }
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite/IgniteCoreRunner.cs b/modules/platforms/dotnet/Apache.Ignite/IgniteCoreRunner.cs
new file mode 100644
index 0000000..1622cce
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite/IgniteCoreRunner.cs
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2019 GridGain Systems, Inc. and Contributors.
+ * 
+ * Licensed under the GridGain Community Edition License (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Configuration;
+    using System.Linq;
+    using System.Threading;
+    using Apache.Ignite.Config;
+    using Apache.Ignite.Core;
+
+    /// <summary>
+    /// Runner class.
+    /// </summary>
+    public static class IgniteCoreRunner
+    {
+        /** Help commands. */
+        private static readonly IList<string> Help = new List<string> { "/help", "-help", "--help" };
+
+        /// <summary>
+        /// Application entry point.
+        /// </summary>
+        internal static void Main(string[] args)
+        {
+            try
+            {
+                // Check for special cases.
+                if (args.Length > 0)
+                {
+                    string first = args[0].ToLowerInvariant();
+
+                    if (Help.Contains(first))
+                    {
+                        ConsoleUtils.PrintHelp("Apache.Ignite.dll", false);
+
+                        return;
+                    }
+                }
+
+                // Pick application configuration first, command line arguments second.
+                var allArgs = AppSettingsConfigurator.GetArgs(ConfigurationManager.AppSettings)
+                    .Concat(ArgsConfigurator.GetArgs(args)).ToArray();
+
+                var ignite = Ignition.Start(Configurator.GetConfiguration(allArgs));
+
+                // Wait until stopped.
+                var evt = new ManualResetEventSlim(false);
+                ignite.Stopped += (s, a) => evt.Set();
+                evt.Wait();
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine("ERROR: " + e);
+
+                Environment.Exit(-1);
+            }
+        }
+    }
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs b/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
index 808d393..422a373 100644
--- a/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/IgniteRunner.cs
@@ -29,7 +29,7 @@ namespace Apache.Ignite
     /// <summary>
     /// Runner class.
     /// </summary>
-    public class IgniteRunner
+    public static class IgniteRunner
     {
         /** Help commands. */
         private static readonly IList<string> Help = new List<string> { "/help", "-help", "--help" };
@@ -60,7 +60,7 @@ namespace Apache.Ignite
 
                     if (Help.Contains(first))
                     {
-                        PrintHelp();
+                        ConsoleUtils.PrintHelp("Apache.Ignite.exe", true);
 
                         return;
                     }
@@ -122,39 +122,6 @@ namespace Apache.Ignite
         }
 
         /// <summary>
-        /// Prints help.
-        /// </summary>
-        private static void PrintHelp()
-        {
-            Console.WriteLine("Usage: Apache.Ignite.exe [/install] [/uninstall] [-options]");
-            Console.WriteLine("");
-            Console.WriteLine("\t/install [-options]    installs Ignite Windows service with provided options.");
-            Console.WriteLine("\t/uninstall             uninstalls Ignite Windows service.");
-            Console.WriteLine("");
-            Console.WriteLine("Options:");
-            Console.WriteLine("\t-IgniteHome            path to Ignite installation directory (if not provided IGNITE_HOME environment variable is used).");
-            Console.WriteLine("\t-ConfigSectionName     name of the IgniteConfigurationSection in app.config to use.");
-            Console.WriteLine("\t-ConfigFileName        path to the app.config file (if not provided Apache.Ignite.exe.config is used).");
-            Console.WriteLine("\t-springConfigUrl       path to Spring configuration file.");
-            Console.WriteLine("\t-jvmDll                path to JVM library jvm.dll (if not provided JAVA_HOME environment variable is used).");
-            Console.WriteLine("\t-jvmClasspath          classpath passed to JVM (enlist additional jar files here).");
-            Console.WriteLine("\t-suppressWarnings      whether to print warnings.");
-            Console.WriteLine("\t-J<javaOption>         JVM options passed to created JVM.");
-            Console.WriteLine("\t-assembly=userLib.dll  additional .NET assemblies to be loaded.");
-            Console.WriteLine("\t-jvmInitialMemoryMB    Initial Java heap size, in megabytes. Maps to -Xms Java parameter. Defaults to 512.");
-            Console.WriteLine("\t-jvmMaxMemoryMB        Maximum Java heap size, in megabytes. Maps to -Xmx Java parameter. Defaults to 1024.");
-            Console.WriteLine("");
-            Console.WriteLine("Examples:");
-            Console.WriteLine("\tApache.Ignite.exe -J-Xms1024m -J-Xmx1024m -springConfigUrl=C:/woer/gg-test/my-test-gg-confignative.xml");
-            Console.WriteLine("\tApache.Ignite.exe -IgniteHome=c:/apache-ignite -jvmClasspath=libs/myLib1.jar;libs/myLib2.jar");
-            Console.WriteLine("\tApache.Ignite.exe -assembly=c:/myProject/libs/lib1.dll -assembly=c:/myProject/libs/lib2.dll");
-            Console.WriteLine("\tApache.Ignite.exe -jvmInitialMemoryMB=1024 -jvmMaxMemoryMB=4096");
-            Console.WriteLine("");
-            Console.WriteLine("Note:");
-            Console.WriteLine("Command line settings have priority over Apache.Ignite.exe.config settings. JVM options and assemblies are concatenated; data from config file comes first, then data from command line.");
-        }
-
-        /// <summary>
         /// Remove the first argument.
         /// </summary>
         /// <param name="args">Arguments.</param>
diff --git a/modules/platforms/dotnet/DEVNOTES.txt b/modules/platforms/dotnet/DEVNOTES.txt
index 199fe90..189f04e 100644
--- a/modules/platforms/dotnet/DEVNOTES.txt
+++ b/modules/platforms/dotnet/DEVNOTES.txt
@@ -5,6 +5,7 @@ Requirements:
 * Windows (XP and up), Windows Server (2008 and up)
 * Oracle JDK 8 and above
 * .NET Framework 4.0
+* .NET Core 2.0+
 * PowerShell 3.0+
 * Visual Studio 2010+
 * JAVA_HOME environment variable set to the corresponding JDK (x64 or x86)
diff --git a/modules/platforms/dotnet/build.ps1 b/modules/platforms/dotnet/build.ps1
index 415087f..6677c1e 100644
--- a/modules/platforms/dotnet/build.ps1
+++ b/modules/platforms/dotnet/build.ps1
@@ -33,6 +33,9 @@ Skip Java build.
 .PARAMETER skipDotNet
 Skip .NET build.
 
+.PARAMETER skipDotNetCore
+Skip .NET Core build.
+
 .PARAMETER skipNuGet
 Skip NuGet packaging.
 
@@ -76,6 +79,7 @@ NuGet version override (normally inferred from assembly version).
 param (
     [switch]$skipJava,
 	[switch]$skipDotNet,
+    [switch]$skipDotNetCore,
     [switch]$skipNuGet,
     [switch]$skipCodeAnalysis,  
     [switch]$clean,
@@ -190,7 +194,7 @@ if (!$skipDotNet) {
 	$codeAnalysis = if ($skipCodeAnalysis) {"/p:RunCodeAnalysis=false"} else {""}
 	$msBuildCommand = "`"$msBuildExe`" Apache.Ignite.sln /target:$targets /p:Configuration=$configuration /p:Platform=`"$platform`" $codeAnalysis /p:UseSharedCompilation=false"
 	echo "Starting MsBuild: '$msBuildCommand'"
-	cmd /c $msBuildCommand
+	cmd /c $msBuildCommand   
 
 	# Check result
 	if ($LastExitCode -ne 0) {
@@ -199,6 +203,27 @@ if (!$skipDotNet) {
 	}
 }
 
+if(!$skipDotNetCore) {
+    
+    # Build core
+    $targetSolution =  ".\Apache.Ignite\Apache.Ignite.DotNetCore.csproj"
+    if ($clean) {
+        $cleanCommand = "dotnet clean $targetSolution -c $configuration"
+        echo "Starting dotnet clean: '$cleanCommand'"
+        cmd /c $cleanCommand
+    }
+
+    $publishCommand = "dotnet publish $targetSolution -c $configuration"
+	echo "Starting dotnet publish: '$publishCommand'"
+	cmd /c $publishCommand    
+
+    # Check result
+    if ($LastExitCode -ne 0) {
+        echo ".NET Core build failed."
+        exit -1
+    }
+}
+
 if ($asmDirs) {
     ls $asmDirs.Split(',') | % `
     {
@@ -218,7 +243,7 @@ if ($asmDirs) {
 }
 
 # Copy binaries
-mkdir -Force bin; del -Force bin\*.*
+mkdir -Force bin; del -Force -Recurse bin\*.*
 
 ls *.csproj -Recurse | where Name -NotLike "*Examples*" `
                      | where Name -NotLike "*Tests*" `