Einrichten von IronOCR in Docker-Containern

This article was translated from English: Does it need improvement?
Translated
View the article in English

Möchten SieOCR von Bildern oder Pdf-Dateien in C# ?

IronOCR unterstützt jetzt vollständig Docker, einschließlich Azure Docker Containers für Linux und Windows.

Docker Linux AWS Windows

Warum Docker verwenden?

Docker ermöglicht es Entwicklern, jede Anwendung als leichtgewichtigen, portablen und autarken Container zu verpacken, auszuliefern und auszuführen, der praktisch überall laufen kann.

IronOCR und Linux-Fibel

Wenn Docker mit .NET für Sie neu ist, empfehlen wir Ihnen diesen ausgezeichneten Artikel über die Einrichtung von Docker-Debugging und Integration mit Visual Studio-Projekten. https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019

Wir empfehlen Ihnen auch die Lektüre unsererIronOCR Linux Setup- und Kompatibilitätsleitfaden

Empfohlene Linux-Docker-Distributionen

Wir empfehlen die unten aufgeführten aktuellen 64-Bit-Linux-Betriebssysteme für die "einfache Konfiguration" von IronPDF.

  • Ubuntu 20
  • Ubuntu 18
  • Debian 11
  • Debian 10 [Derzeit die Microsoft Azure Standard-Linux-Distro]

    Wir empfehlen die Verwendung von MicrosoftsOffizielle Docker-Bilder . Andere Linux-Distributionen werden zum Teil unterstützt, erfordern aber möglicherweise eine manuelle Konfiguration mit apt-get. Siehe unser "Linux Manuelle Einrichtung" Leitfaden

    Funktionierende Docker-Dateien für Ubuntu und Debian sind in diesem Dokument enthalten:

IronOCR Linux Docker Installation Essentials

Verwenden Sie unser NuGet-Paket

Wir empfehlen die Verwendung desIronOcr NuGet-Paket funktioniert bei der Entwicklung unter Windows, macOS und Linux.

PM> Install-Package IronOcr

Ubuntu Linux DockerFiles

Docker Linux Ubuntu

Ubuntu 20 mit .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 mit .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 mit .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

Docker Linux Debian

Debian 11 mit .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 mit .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 mit .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 mit .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"]