Skip to content

EPPlus 5 and Docker

JanKallman edited this page Oct 19, 2023 · 2 revisions

If you use the .NET core version of EPPlus you can run it inside a Linux Docker container.
Here below you will find a few examples of Docker files that we have tested with various Linux distributions (to publish an ASP.NET Core 3.1 web application that references EPPlus 5).

Alpine

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.9-alpine3.12 AS base
WORKDIR /app

#installs libgdiplus to support System.Drawing for handling of graphics
RUN apk add libgdiplus --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
#installs some standard fonts needed for Autofit columns support
RUN apk --no-cache add msttcorefonts-installer fontconfig freetype-dev libjpeg-turbo-dev libpng-dev && \
    update-ms-fonts && \
    fc-cache -f

EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1.9-alpine3.12 AS build
WORKDIR /src
COPY ["your-project-name.csproj", ""]
RUN dotnet restore "./your-project-name.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "your-project-name.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "your-project-name.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "your-project-name.dll"]

CentOS 7

FROM centos:7 AS base
WORKDIR /app

RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum install -y dotnet-sdk-3.1
RUN yum install -y aspnetcore-runtime-3.1
RUN yum install -y epel-release
#installs libgdiplus to support System.Drawing for handling of graphics
RUN yum install -y libgdiplus
#installs some standard fonts needed for Autofit columns support
RUN yum install curl cabextract xorg-x11-font-utils fontconfig
RUN yum install https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm

EXPOSE 80
EXPOSE 443

FROM centos:7 AS build
WORKDIR /src
COPY ["your-project-name.csproj", ""]
RUN dotnet restore "./your-project-name.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "your-project-name.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "your-project-name.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "your-project-name.dll"]

Debian

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app

#installs libgdiplus to support System.Drawing for handling of graphics
RUN apt-get update && apt-get install -y libgdiplus
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
#installs some standard fonts needed for Autofit columns support
RUN apt-get update && apt-get install -y ttf-mscorefonts-installer fontconfig

EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["your-project-name.csproj", ""]
RUN dotnet restore "./your-project-name.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "your-project-name.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "your-project-name.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "your-project-name.dll"]

Ubuntu

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.9-focal AS base
WORKDIR /app

#installs libgdiplus to support System.Drawing for handling of graphics
RUN apt-get update && apt-get install -y libgdiplus

##Install fonts if needed...

EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1.9-focal AS build
WORKDIR /src
COPY ["your-project-name.csproj", ""]
RUN dotnet restore "./your-project-name.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "your-project-name.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "your-project-name.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "your-project-name.dll"]

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally