Configuración de IronOCR en contenedores Docker

Desea OCR de imágenes o archivos Pdf en C# ?

IronOCR es ahora totalmente compatible con Docker, incluidos Azure Docker Containers para Linux y Windows.

¿Por qué utilizar Docker?

Docker permite a los desarrolladores empaquetar, enviar y ejecutar fácilmente cualquier aplicación como un contenedor ligero, portátil y autosuficiente, que puede ejecutarse prácticamente en cualquier lugar.

Introducción a IronOCR y Linux

Si Docker con .NET es nuevo para ti, te recomendamos este excelente artículo sobre cómo configurar la depuración e integración de Docker con proyectos de Visual Studio. https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019

También le recomendamos encarecidamente que lea nuestro Guía de instalación y compatibilidad de IronOCR con Linux

Distribuciones Linux Docker recomendadas

Recomendamos a continuación los últimos sistemas operativos Linux de 64 bits para una "configuración sencilla" de IronPDF.

  • Ubuntu 20
  • Ubuntu 18
  • Debian 11
  • Debian 10 [Actualmente la distribución Linux predeterminada de Microsoft Azure]

    Recomendamos utilizar la aplicación de Microsoft Imágenes Docker oficiales . Otras distribuciones de Linux son compatibles en parte, pero pueden requerir una configuración manual mediante apt-get. Consulte nuestro "Configuración manual de Linux"Guía

    En este documento se incluyen archivos Docker de trabajo para Ubuntu y Debian:

Fundamentos de la instalación de IronOCR Linux Docker

Utilice nuestro paquete NuGet

Recomendamos utilizar el IronOcr NuGet Package funciona cuando se desarrolla en Windows , macOS y Linux.

PM> Install-Package IronOcr

Ubuntu Linux DockerFiles

Ubuntu 20 con .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 con .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 con .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 con .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 con .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 con .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 con .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"]