Publish Winnovative PDF Next ASP.NET Demo to Docker on Linux

This guide explains how to build and run a Docker container for a published ASP.NET Core application using Winnovative PDF Next on Linux.

Compatibility with Linux Docker Images

Winnovative PDF Next can run in various Linux Docker containers that have the ASP.NET Core runtime preinstalled, such as Linux Debian 12 with ASP.NET Core Runtime 8.0 using the mcr.microsoft.com/dotnet/aspnet:8.0 image reference and Linux Ubuntu 24.04 with ASP.NET Core Runtime 10.0 using the mcr.microsoft.com/dotnet/aspnet:10.0 image reference.

Publish the Demo Application to a Folder

Download the Winnovative PDF Next ZIP package from the website downloads page and extract it to a folder on your machine. In the Linux folder of the extracted package you can find the demo application that references the Winnovative PDF Next library NuGet package for Linux. You can open the Winnovative_Next_AspNetDemo_Linux.csproj file in Visual Studio and publish it to a folder or publish it from the command line.

To publish from the command line, run the following command in the application folder containing the Winnovative_Next_AspNetDemo_Linux.csproj project file:

bash
dotnet publish -c Release -r linux-x64 -o publish Winnovative_Next_AspNetDemo_Linux.csproj

You can find more details about building and publishing the Winnovative PDF Next demo applications in the Build and Publish Demo Applications guide in the documentation.

The publish folder should include the main DLL (for example, Winnovative_Next_AspNetDemo_Linux.dll) and the winnovative_runtimes directory at the root level.

Place this publish folder in the build context folder of the Linux host file system, which will also contain the Dockerfile.

Create the Dockerfile for Linux with Preinstalled ASP.NET Core Runtime

Winnovative PDF Next can run in Linux containers with the ASP.NET Core runtime.

Below you can find the Dockerfile configurations for the default Linux Debian 12 with ASP.NET Core Runtime 8.0 and Linux Ubuntu 24.04 with ASP.NET Core Runtime 10.0 images. Copy the contents into a file named Dockerfile and place it in the build context folder together with the publish folder.

You can also customize the Dockerfile to use other Linux distributions that have the ASP.NET Core runtime preinstalled. As an example is provided a Dockerfile for Linux Ubuntu 22.04 (jammy) with ASP.NET Core Runtime 8.0 using mcr.microsoft.com/dotnet/aspnet:8.0-jammy image.

The Dockerfile installs the required Linux dependencies, copies the published application into the image, grants execute permissions to the Winnovative PDF Next runtime and configures the container to run the demo application on port 27101.

Dockerfile for Linux Debian 12 with Preinstalled ASP.NET Core Runtime 8.0

 
FROM mcr.microsoft.com/dotnet/aspnet:8.0

# Install Winnovative PDF dependencies
RUN apt-get update && \
    apt-get install -y \
        libnss3 \
        libatk-bridge2.0-0 \
        libcairo2 \
        libpango-1.0-0 && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the published ASP.NET Core app files from the publish folder into the image
COPY publish/ .

# Ensure execute permissions for Winnovative HTML to PDF runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_loadhtml

# Ensure execute permissions for Winnovative PDF Processor runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_pdfprocessor

# Expose the port used by the app
EXPOSE 27101

# Set the ASP.NET Core application to listen on port 27101
ENV ASPNETCORE_URLS=http://+:27101

# Start the application
ENTRYPOINT ["dotnet", "Winnovative_Next_AspNetDemo_Linux.dll"]

Dockerfile for Linux Ubuntu 24.04 with Preinstalled ASP.NET Core Runtime 10.0

 
FROM mcr.microsoft.com/dotnet/aspnet:10.0

# Install Winnovative PDF dependencies
RUN apt-get update && \
    apt-get install -y \
        libnss3 \
        libatk-bridge2.0-0 \
        libcairo2 \
        libpango-1.0-0 && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the published ASP.NET Core app files from the publish folder into the image
COPY publish/ .

# Ensure execute permissions for Winnovative HTML to PDF runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_loadhtml

# Ensure execute permissions for Winnovative PDF Processor runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_pdfprocessor

# Expose the port used by the app
EXPOSE 27101

# Set the ASP.NET Core application to listen on port 27101
ENV ASPNETCORE_URLS=http://+:27101

# Start the application
ENTRYPOINT ["dotnet", "Winnovative_Next_AspNetDemo_Linux.dll"]

Dockerfile for Linux Ubuntu 22.04 with Preinstalled ASP.NET Core Runtime 8.0

 
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy

# Install Winnovative PDF dependencies
RUN apt-get update && \
    apt-get install -y \
        libnss3 \
        libatk-bridge2.0-0 \
        libcairo2 \
        libpango-1.0-0 && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the published ASP.NET Core app files from the publish folder into the image
COPY publish/ .

# Ensure execute permissions for Winnovative HTML to PDF runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_loadhtml

# Ensure execute permissions for Winnovative PDF Processor runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_pdfprocessor

# Expose the port used by the app
EXPOSE 27101

# Set the ASP.NET Core application to listen on port 27101
ENV ASPNETCORE_URLS=http://+:27101

# Start the application
ENTRYPOINT ["dotnet", "Winnovative_Next_AspNetDemo_Linux.dll"]

Create the Dockerfile for Linux with ASP.NET Core Runtime and Microsoft Core Fonts

Winnovative PDF Next can run in Linux containers with the ASP.NET Core runtime preinstalled. Additionally, you can install the Microsoft Core Fonts to offer better font rendering for documents that use these fonts.

Below you can find the Dockerfile configurations for Linux Debian 12 with ASP.NET Core Runtime 8.0 and Linux Ubuntu 24.04 with ASP.NET Core Runtime 10.0. Copy the contents into a file named Dockerfile and place it in the build context folder together with the publish folder.

You can also customize the Dockerfile to use other Linux distributions that have the ASP.NET Core runtime preinstalled. As an example is provided a Dockerfile for Linux Ubuntu 22.04 (jammy) with ASP.NET Core Runtime 8.0 using mcr.microsoft.com/dotnet/aspnet:8.0-jammy image.

The Dockerfile installs the required Linux dependencies and the optional Microsoft Core Fonts, copies the published application into the image, grants execute permissions to the Winnovative PDF Next runtime and configures the container to run the demo application on port 27101.

Dockerfile for Linux Debian 12 with ASP.NET Core Runtime 8.0 and Microsoft Core Fonts

 
FROM mcr.microsoft.com/dotnet/aspnet:8.0

# Install Winnovative PDF dependencies and the optional Microsoft Core Fonts
RUN apt-get update && \
    apt-get install -y \
        libnss3 \
        libatk-bridge2.0-0 \
        libcairo2 \
        libpango-1.0-0 \
        wget \
        debconf-utils && \
    echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | debconf-set-selections && \
    wget -O /tmp/ttf-mscorefonts-installer_3.8_all.deb http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.8_all.deb && \
    apt-get install -y /tmp/ttf-mscorefonts-installer_3.8_all.deb && \
    fc-cache -f -v && \
    rm -f /tmp/ttf-mscorefonts-installer_3.8_all.deb && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the published ASP.NET Core app files from the publish folder into the image
COPY publish/ .

# Ensure execute permissions for Winnovative HTML to PDF runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_loadhtml

# Ensure execute permissions for Winnovative PDF Processor runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_pdfprocessor

# Expose the port used by the app
EXPOSE 27101

# Set the ASP.NET Core application to listen on port 27101
ENV ASPNETCORE_URLS=http://+:27101

# Start the application
ENTRYPOINT ["dotnet", "Winnovative_Next_AspNetDemo_Linux.dll"]

Dockerfile for Linux Ubuntu 24.04 with ASP.NET Core Runtime 10.0 and Microsoft Core Fonts

 
FROM mcr.microsoft.com/dotnet/aspnet:10.0

# Install Winnovative PDF dependencies and the optional Microsoft Core Fonts
RUN apt-get update && \
    apt-get install -y \
        libnss3 \
        libatk-bridge2.0-0 \
        libcairo2 \
        libpango-1.0-0 \
        wget \
        debconf-utils && \
    echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | debconf-set-selections && \
    wget -O /tmp/ttf-mscorefonts-installer_3.8_all.deb http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.8_all.deb && \
    apt-get install -y /tmp/ttf-mscorefonts-installer_3.8_all.deb && \
    fc-cache -f -v && \
    rm -f /tmp/ttf-mscorefonts-installer_3.8_all.deb && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the published ASP.NET Core app files from the publish folder into the image
COPY publish/ .

# Ensure execute permissions for Winnovative HTML to PDF runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_loadhtml

# Ensure execute permissions for Winnovative PDF Processor runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_pdfprocessor

# Expose the port used by the app
EXPOSE 27101

# Set the ASP.NET Core application to listen on port 27101
ENV ASPNETCORE_URLS=http://+:27101

# Start the application
ENTRYPOINT ["dotnet", "Winnovative_Next_AspNetDemo_Linux.dll"]

Dockerfile for Linux Ubuntu 22.04 with ASP.NET Core Runtime 8.0 and Microsoft Core Fonts

 
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy

# Install Winnovative PDF dependencies and the optional Microsoft Core Fonts
RUN apt-get update && \
    apt-get install -y \
        libnss3 \
        libatk-bridge2.0-0 \
        libcairo2 \
        libpango-1.0-0 \
        wget \
        debconf-utils && \
    echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | debconf-set-selections && \
    wget -O /tmp/ttf-mscorefonts-installer_3.8_all.deb http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.8_all.deb && \
    apt-get install -y /tmp/ttf-mscorefonts-installer_3.8_all.deb && \
    fc-cache -f -v && \
    rm -f /tmp/ttf-mscorefonts-installer_3.8_all.deb && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the published ASP.NET Core app files from the publish folder into the image
COPY publish/ .

# Ensure execute permissions for Winnovative HTML to PDF runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_loadhtml

# Ensure execute permissions for Winnovative PDF Processor runtime
RUN chmod +x /app/winnovative_runtimes/linux-x64/native/winnovative_pdfprocessor

# Expose the port used by the app
EXPOSE 27101

# Set the ASP.NET Core application to listen on port 27101
ENV ASPNETCORE_URLS=http://+:27101

# Start the application
ENTRYPOINT ["dotnet", "Winnovative_Next_AspNetDemo_Linux.dll"]

Build and Run the Container

Once the Dockerfile is created as described in the previous sections, you can build and run the container using the following commands.

Use the following command to build the Docker image:

 
docker build -t winnovative-pdf-next-demo-image-linux .

Then run the container:

 
docker run -d -p 27101:27101 --name winnovative-pdf-next-demo-app-linux winnovative-pdf-next-demo-image-linux

Open your browser and access the application at:

 
http://localhost:27101

You can also publish the Docker image to Azure Container Registry (ACR) and run the application directly from there, enabling easier deployment and integration within Azure-based environments.

See Also