diff --git a/Examples/.dockerignore b/Examples/.dockerignore new file mode 100644 index 000000000..bdca33b44 --- /dev/null +++ b/Examples/.dockerignore @@ -0,0 +1,25 @@ +**/.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 \ No newline at end of file diff --git a/Examples/GroupDocs.Viewer.Examples.CSharp.Core/Dockerfile b/Examples/GroupDocs.Viewer.Examples.CSharp.Core/Dockerfile new file mode 100644 index 000000000..3fb145c70 --- /dev/null +++ b/Examples/GroupDocs.Viewer.Examples.CSharp.Core/Dockerfile @@ -0,0 +1,49 @@ +# Navigate to 'Examples' folder +# Build container image with `docker build -f "GroupDocs.Viewer.Examples.CSharp.Core\Dockerfile" -t groupdocs-viewer:examples .` +# Run container `docker run -it --rm -v ${pwd}/Output:/app/Output groupdocs-viewer:examples` +# Or run 'Docker' profile in Visual Studio + +FROM mcr.microsoft.com/dotnet/runtime:3.1-bionic AS base +WORKDIR /app + +# begin install libgdiplus and dependencies +RUN apt-get update \ + && apt-get install -y \ + apt-transport-https \ + dirmngr \ + gnupg \ + ca-certificates + +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \ + && echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" >> /etc/apt/sources.list.d/mono-official-stable.list + +RUN apt-get update \ + && apt-get install -y --allow-unauthenticated \ + libc6-dev \ + libgdiplus \ + libx11-dev + +# begin ttf-mscorefonts-installer +RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \ + && apt-get update \ + && apt-get install -y \ + libfontconfig1 \ + xfonts-utils \ + ttf-mscorefonts-installer +# end ttf-mscorefonts-installer + +FROM mcr.microsoft.com/dotnet/sdk:3.1-bionic AS build +WORKDIR /src +COPY ["GroupDocs.Viewer.Examples.CSharp.Core/GroupDocs.Viewer.Examples.CSharp.Core.csproj", "GroupDocs.Viewer.Examples.CSharp.Core/"] +RUN dotnet restore "GroupDocs.Viewer.Examples.CSharp.Core/GroupDocs.Viewer.Examples.CSharp.Core.csproj" +COPY . . +WORKDIR "/src/GroupDocs.Viewer.Examples.CSharp.Core" +RUN dotnet build "GroupDocs.Viewer.Examples.CSharp.Core.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "GroupDocs.Viewer.Examples.CSharp.Core.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "GroupDocs.Viewer.Examples.CSharp.Core.dll"] \ No newline at end of file diff --git a/Examples/GroupDocs.Viewer.Examples.CSharp.Core/GroupDocs.Viewer.Examples.CSharp.Core.csproj b/Examples/GroupDocs.Viewer.Examples.CSharp.Core/GroupDocs.Viewer.Examples.CSharp.Core.csproj index 7f03a3ab6..c682900b7 100644 --- a/Examples/GroupDocs.Viewer.Examples.CSharp.Core/GroupDocs.Viewer.Examples.CSharp.Core.csproj +++ b/Examples/GroupDocs.Viewer.Examples.CSharp.Core/GroupDocs.Viewer.Examples.CSharp.Core.csproj @@ -3,12 +3,15 @@ Exe netcoreapp3.1 + Linux + + - + \ No newline at end of file diff --git a/Examples/GroupDocs.Viewer.Examples.CSharp.Core/Properties/launchSettings.json b/Examples/GroupDocs.Viewer.Examples.CSharp.Core/Properties/launchSettings.json new file mode 100644 index 000000000..57ad31b86 --- /dev/null +++ b/Examples/GroupDocs.Viewer.Examples.CSharp.Core/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "GroupDocs.Viewer.Examples.CSharp.Core": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/Examples/GroupDocs.Viewer.Examples.CSharp.Core/RunExamples.cs b/Examples/GroupDocs.Viewer.Examples.CSharp.Core/RunExamples.cs index 329e4d42f..efdf9b0e6 100644 --- a/Examples/GroupDocs.Viewer.Examples.CSharp.Core/RunExamples.cs +++ b/Examples/GroupDocs.Viewer.Examples.CSharp.Core/RunExamples.cs @@ -237,7 +237,6 @@ static void Main() Console.WriteLine(); Console.WriteLine("All done."); - Console.ReadKey(); } } } diff --git a/Examples/GroupDocs.Viewer.Examples.CSharp/TestFiles.cs b/Examples/GroupDocs.Viewer.Examples.CSharp/TestFiles.cs index 435299c6d..51989f4ad 100644 --- a/Examples/GroupDocs.Viewer.Examples.CSharp/TestFiles.cs +++ b/Examples/GroupDocs.Viewer.Examples.CSharp/TestFiles.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.IO; +using System.Runtime.InteropServices; namespace GroupDocs.Viewer.Examples.CSharp { @@ -151,7 +153,14 @@ public static class TestFiles public static string SAMPLE_CHM => GetSampleFilePath("sample.chm"); - private static string GetSampleFilePath(string filePath) => - Path.Combine(Utils.SamplesPath, filePath); + private static string GetSampleFilePath(string filePath) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + return Path.Combine(Utils.SamplesPath, filePath); + + var assembly = System.Reflection.Assembly.GetEntryAssembly(); + var entryAssemblyDirectory = Path.GetDirectoryName(assembly.Location); + return Path.Combine(entryAssemblyDirectory, Utils.SamplesPath, filePath); + } } } \ No newline at end of file