在 Docker 容器中设置 IronXL
生成PDF文件使用 C# 阅读、编辑和创建 Excel 电子表格文件?
IronXL 现已全面支持 Docker,包括适用于 Linux 和 Windows 的 Azure Docker 容器。
为什么使用 Docker?
Docker 使开发人员能够轻松打包、传输和运行任何应用程序作为轻量级、便携式、自足的容器,几乎可以在任何地方运行。
IronXL 和 Linux 入门
如果您刚接触Docker与.NET, 我们推荐这篇关于设置Docker调试和与Visual Studio项目集成的优秀文章。 https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019
我们还强烈建议您阅读我们的IronXL Linux 安装和兼容性指南
推荐的Linux Docker发行版
我们推荐以下最新的64位Linux操作系统,以便于配置IronPDF。
- 乌班图 20
- Ubuntu 18
- Debian 11
- Debian 10[目前,Microsoft Azure 默认 Linux Distro]_
- CentOS 7
CentOS 8
我们建议使用Microsoft的官方 Docker 映像 . 其他 Linux 发行版部分支持,但可能需要使用 apt-get 手动配置。 请参阅我们的“Linux 手动设置“指南”
本文件包括适用于Ubuntu和Debian的工作Docker文件:
IronXL Linux Docker 安装要点
使用我们的 NuGet 包
我们建议使用IronXLNuGet 软件包可在 Windows、macOS 和 Linux 上进行开发。
Install-Package IronXL.Excel
Ubuntu Linux DockerFiles
Ubuntu 20 与 .NET 5
基础运行时镜像(Ubuntu 20带.NET运行时)
FROM mcr.microsoft.com/dotnet/runtime:5.0-focal AS base
WORKDIR /app
基础开发镜像(Ubuntu 20带.NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]
配备 .NET 3.1 LTS 的 Ubuntu 20
基础运行时镜像(Ubuntu 20带.NET运行时)
FROM mcr.microsoft.com/dotnet/runtime:3.1-focal AS base
WORKDIR /app
基础开发镜像(Ubuntu 20带.NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:3.1-focal AS build
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]
Ubuntu 18 与 .NET 3.1 LTS
基础运行时映像(Ubuntu 18 附带 .NET 运行时)
FROM mcr.microsoft.com/dotnet/runtime:3.1-bionic AS base
WORKDIR /app
基础开发镜像(Ubuntu 18 附带 .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:3.1-bionic AS build
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]
Debian Linux DockerFiles
配备 .NET 5 的 Debian 11
基础运行时镜像(带有 .NET 运行时的 Debian 10)
FROM mcr.microsoft.com/dotnet/aspnet:5.0-bullseye-slim AS base
WORKDIR /app
基础开发镜像(Debian 10 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:5.0-bullseye-slim AS build
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]
配备 .NET 3.1 LTS 的 Debian 11
基础运行时镜像(带有 .NET 运行时的 Debian 10)
FROM mcr.microsoft.com/dotnet/aspnet:3.1-bullseye-slim AS base
WORKDIR /app
基础开发镜像(Debian 10 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:3.1-bullseye-slim AS build
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]
Debian 10 与 .NET 5
基础运行时镜像(带有 .NET 运行时的 Debian 10)
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app
基础开发镜像(Debian 10 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]
配备 .NET 3.1 LTS 的 Debian 10
基础运行时镜像(带有 .NET 运行时的 Debian 10)
FROM mcr.microsoft.com/dotnet/runtime:3.1 AS base
WORKDIR /app
基础开发镜像(Debian 10 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]
CentOS 7 与 .NET 3.1 LTS
基础运行时镜像(CentOS 7)
FROM centos:7 AS base
WORKDIR /app
安装必要的软件包
执行 yum install sudo -y
RUN sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN sudo yum install dotnet-sdk-3.1 -y
RUN sudo yum install aspnetcore-runtime-3.1 -y
RUN sudo yum install dotnet-runtime-3.1 -y
RUN sudo yum update -y
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]
CentOS 8与.NET 3.1 LTS
基础运行时映像(CentOS 8)
FROM centos:8 AS 基础
WORKDIR /app
安装必要的软件包
执行 yum install sudo -y
RUN sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN sudo yum install dotnet-sdk-3.1 -y
RUN sudo yum install aspnetcore-runtime-3.1 -y
RUN sudo yum install dotnet-runtime-3.1 -y
RUN sudo yum update -y
WORKDIR /src
还原 NuGet 包
COPY["Example/Example.csproj"、"Example/"]
RUN dotnet restore "Example/Example.csproj"
构建项目
COPY .
WORKDIR "/src/例子"
运行 dotnet build "Example.csproj" -c Release -o /app/build
发布项目
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
运行应用程序
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT["dotnet"、"Example.dll"]