Mise en place d'IronOCR dans des conteneurs Docker
VouloirOCR d'images ou de fichiers Pdf en C# ?
IronOCR prend désormais entièrement en charge Docker, notamment Azure Docker Containers pour Linux et Windows.
Pourquoi utiliser Docker ?
Docker permet aux développeurs d'emballer, d'expédier et d'exécuter facilement n'importe quelle application sous la forme d'un conteneur léger, portable et autonome, qui peut fonctionner pratiquement n'importe où.
IronOCR et Linux : notions de base
Si Docker avec .NET est nouveau pour vous, nous vous recommandons cet excellent article sur la configuration du débogage et de l'intégration de Docker avec les projets Visual Studio. https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019
Nous vous recommandons également de lire notreGuide d'installation et de compatibilité d'IronOCR Linux
Distributions Linux Docker recommandées
Nous recommandons les derniers systèmes d'exploitation Linux 64 bits ci-dessous pour une "configuration facile" d'IronPDF.
- Ubuntu 20
- Ubuntu 18
- Debian 11
Debian 10 [Actuellement, la distribution Linux par défaut de Microsoft Azure]
Nous recommandons d'utiliser le logicielImages Docker officielles . Les autres distributions Linux sont partiellement prises en charge, mais peuvent nécessiter une configuration manuelle à l'aide d'apt-get. Voir notre "Configuration manuelle de Linux"Guide de l'utilisateur
Les fichiers Docker pour Ubuntu et Debian sont inclus dans ce document :
IronOCR Linux Docker Installation Essentials
Utiliser notre paquetage NuGet
Nous recommandons d'utiliser leIronOCR NuGet Package il fonctionne pour le développement sur Windows, macOS et Linux.
PM> Install-Package IronOcr
Ubuntu Linux DockerFiles
Ubuntu 20 avec .NET 5
# base runtime image (Ubuntu 20 w/ .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:5.0-focal AS base
WORKDIR /app
# install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# base development image (Ubuntu 20 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build
WORKDIR /src
# restore NuGet packages
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 20 avec .NET 3.1 LTS
# base runtime image (Ubuntu 20 w/ .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:3.1-focal AS base
WORKDIR /app
# install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# base development image (Ubuntu 20 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:3.1-focal AS build
WORKDIR /src
# restore NuGet packages
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 avec .NET 3.1 LTS
# base runtime image (Ubuntu 18 w/ .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:3.1-bionic AS base
WORKDIR /app
# install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# base development image (Ubuntu 18 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:3.1-bionic AS build
WORKDIR /src
# restore NuGet packages
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 Linux DockerFiles
Debian 11 avec .NET 5
# base runtime image (Debian 10 w/ .NET runtime)
FROM mcr.microsoft.com/dotnet/aspnet:5.0-bullseye-slim AS base
WORKDIR /app
# install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# base development image (Debian 10 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:5.0-bullseye-slim AS build
WORKDIR /src
# restore NuGet packages
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 11 avec .NET 3.1 LTS
# base runtime image (Debian 10 w/ .NET runtime)
FROM mcr.microsoft.com/dotnet/aspnet:3.1-bullseye-slim AS base
WORKDIR /app
# install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# base development image (Debian 10 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:3.1-bullseye-slim AS build
WORKDIR /src
# restore NuGet packages
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 avec .NET 5
# base runtime image (Debian 10 w/ .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app
# install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# base development image (Debian 10 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
# restore NuGet packages
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 avec .NET 3.1 LTS
# base runtime image (Debian 10 w/ .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:3.1 AS base
WORKDIR /app
# install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# base development image (Debian 10 w/ .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
# restore NuGet packages
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"]