在 Docker 容器中設置 IronXL
IronXL 現在完全支援 Docker,包括 Azure Docker Containers for Linux 和 Windows。
為什麼使用 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。
- Ubuntu 20
- Ubuntu 18
- Debian 11
- Debian 10[目前的 Microsoft Azure 預設 Linux 發行版]_
- CentOS 7
- CentOS 8
我們建議使用微軟的 官方 Docker 映像檔 . 其他 Linux 發行版受到部分支持,但可能需要使用 apt-get 進行手動配置。請參閱我們的 "Linux 手動設置"指南
在本文件中包括適用於Ubuntu和Debian的運行中的Docker文件:"
IronXL Linux Docker 安裝要點
使用我們的 NuGet 套件
我們建議使用 IronXL NuGet 套件在 Windows、macOS 和 Linux 上開發時運行良好。
Install-Package IronXL.Excel
Ubuntu Linux DockerFiles
Ubuntu Linux DockerFiles
Ubuntu 20 與 .NET 5
# 基本運行時鏡像 (Ubuntu 20 搭配 .NET 執行環境)
來自 mcr.microsoft.com/dotnet/runtime:5.0-focal AS base
WORKDIR /app
基礎開發鏡像 (Ubuntu 20 搭配 .NET SDK)
從 mcr.microsoft.com/dotnet/sdk:5.0-focal 作為 build
工作目錄 /src
# 恢復 NuGet 套件
複製 ["Example/Example.csproj", "Example/"]
```
RUN dotnet restore "Example/Example.csproj"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ``` [「dotnet」、「Example.dll」]
Ubuntu 20 與 .NET 3.1 LTS
# 基本運行時影像 (Ubuntu 20 搭配 .NET 執行環境)
來自mcr.microsoft.com/dotnet/runtime:3.1-focal作為base
工作目錄 /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"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ``` [「dotnet」、「Example.dll」]
Ubuntu 18 with .NET 3.1 LTS
# 基础运行时镜像 (Ubuntu 18 w/ .NET 运行时)
來自 mcr.microsoft.com/dotnet/runtime:3.1-bionic AS base
WORKDIR /app
基本開發映像檔 (Ubuntu 18 搭配 .NET SDK)
來自 mcr.microsoft.com/dotnet/sdk:3.1-bionic 作為 build
工作目錄 /src
# 恢復 NuGet 套件
複製 ["Example/Example.csproj", "Example/"]
```
RUN dotnet restore "Example/Example.csproj"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ``` [「dotnet」、「Example.dll」]
Debian Linux DockerFiles
Debian 11 with .NET 5
# 基本運行時映像 (Debian 10 搭配 .NET 執行環境)
FROM mcr.microsoft.com/dotnet/aspnet:5.0-bullseye-slim AS base
WORKDIR /app
# base 開發映像檔 (Debian 10 搭配 .NET SDK)
從 mcr.microsoft.com/dotnet/sdk:5.0-bullseye-slim 作為 build
工作目錄 /src
# 還原 NuGet 套件
複製 ["Example/Example.csproj", "Example/"]
```
RUN dotnet restore "Example/Example.csproj"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ``` [「dotnet」、「Example.dll」]
Debian 11 與 .NET 3.1 LTS
# 基礎運行時映像
``` (Debian 10 搭配 .NET 執行環境)
從 mcr.microsoft.com/dotnet/aspnet:3.1-bullseye-slim 作為 base
工作目錄 /app
# 基礎開發映像檔 (Debian 10 搭配 .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"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ``` [「dotnet」、「Example.dll」]
Debian 10 with .NET 5
# 基本運行時映像
(Debian 10 搭配 .NET 執行環境)
來自 mcr.microsoft.com/dotnet/runtime:5.0 作為基礎
工作目錄 /app
基礎開發映像檔 (Debian 10 搭配 .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"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ``` [「dotnet」、「Example.dll」]
Debian 10 與 .NET 3.1 LTS
# 基礎運行時映像 (Debian 10 搭配 .NET 執行環境)
從 mcr.microsoft.com/dotnet/runtime:3.1 作為 base
工作目錄 /app
基本開發映像檔 (Debian 10 搭配 .NET SDK)
從 mcr.microsoft.com/dotnet/sdk:3.1 作為構建階段
WORKDIR /src
恢復 NuGet 套件
COPY ["Example/Example.csproj", "Example/"]
```
RUN dotnet restore "Example/Example.csproj"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
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
安裝必要的套件
RUN 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"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ``` [「dotnet」、「Example.dll」]
CentOS 8 與 .NET 3.1 LTS
#基礎運行時映像 (CentOS 8)
```plaintext
FROM centos:8 AS base
WORKDIR /app
安裝必要的套件
RUN 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"
build project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
publish project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ``` [「dotnet」、「Example.dll」]