跳轉到主要內容
此主題也提供 Linux 版本。
本節說明如何在 Docker 容器中執行 ABBYY FineReader Engine 12。此情境會使用兩個容器:
  1. 一個執行 ABBYY FineReader Engine 的容器
  2. 一個執行授權服務的容器
實作此情境可提升容錯能力,並確保所有容器持續運作。如果其中一個容器發生故障,您可以重新啟動該容器,而不會中斷另一個容器。 此情境使用會連線至 *.abbyy.com 授權伺服器的 線上授權
ABBYY 授權服務在同一時間只能搭配一個線上授權運作。
您需要準備:
無論 ABBYY 授權服務安裝在何處,若要使用線上授權,都必須符合下列條件:
  • 可用的網際網路連線
  • 允許透過連接埠 443 (HTTPS) 連線至 *.abbyy.com
  • GoDaddy Trusted Root Certification Authority
Certification Authority 的 GoDaddy 根憑證應安裝在本機電腦版本的 Trusted Root Certification Authorities 憑證存放區中。如需憑證的詳細資訊,請參閱 GoDaddy 網站
若要在 Docker 容器中執行 ABBYY FineReader Engine 12:
  1. 在您的電腦上下載並安裝 Docker for Windows
  2. 啟用 Windows 的 Hyper-V 和 Containers 功能。
  3. 在安裝容器期間,選取「Use Windows containers instead of Linux containers」選項。
  4. 建立一個空目錄,並將下列內容放入其中:
  • docker-compose.yml — Docker Compose 的組態檔 (請參閱下方清單)
  • TestAppFolder — 一個目錄,其中包含
    • 線上授權權杖檔案
    • 已編譯的測試應用程式,使用此權杖檔案、其密碼,以及您的 Customer Project ID
  • Dockerfile_ls — 用於執行授權服務容器的 Dockerfile (請參閱下方清單)
Dockerfile_ls 用於建置僅與一個由 Dockerfile_worker 建置的容器搭配運作的容器。請勿將多個執行 ABBYY FineReader Engine 的容器複本設定為搭配單一授權服務運作。
  • LicensingSettings_ls.xml - 包含授權服務授權參數的檔案 (請參閱下方清單)
  • DeployLS.ps1 — 用於啟動授權服務的指令碼 (請參閱下方清單)
注意:此指令碼會使用 /standalone 索引鍵執行授權服務。使用此索引鍵時,授權服務會以前景處理程序的方式執行,這是在 Docker 容器中運作的最佳做法。
  • Dockerfile_worker — 用於建立包含 ABBYY FineReader Engine 和測試應用程式之容器的 Dockerfile (請參閱下方清單)
  • LicensingSettings_worker.xml - 包含 ABBYY FineReader Engine 程式庫授權參數的檔案 (請參閱下方清單)
  • SetUpWorkerLicensing.ps1 - 用於將 LicensingSettings_worker.xml 中的伺服器名稱替換為 docker-compose.yml 中指定名稱的指令碼 (請參閱下方清單)
  • RunTestApp.ps1 — 用於執行測試應用程式的命令列指令碼 (請參閱下方清單)
  1. 使用以下命令將 ABBYY FineReader Engine 發行套件解壓縮到先前建立的目錄中:
installRnt64.exe /extract InstallDir="<your_directory>/FRE"
  1. 若要建置並執行容器,請使用下列命令:
docker-compose up
執行測試應用程式後,結果會顯示在主控台中。
如果您使用 Windows Server Core 作為容器基礎映像,請在部署 ABBYY FineReader Engine 後設定字型,如 使用字型 所述。
version: '3'
services:
  ls:
    build:
      context: .
      dockerfile: Dockerfile_ls
    hostname: servername
    networks:
      frenet:
        aliases:
          - servername
    restart: on-failure
  worker:
    build:
      context: .
      dockerfile: Dockerfile_worker
      args:
        - service_address=servername
    depends_on:
      - ls
    networks:
      frenet:
    restart: on-failure
networks:
  frenet:
Dockerfile_ls
# 複製授權服務
FROM mcr.microsoft.com/windows/servercore:ltsc2019 as fre12_ls
WORKDIR /app
ADD ./FRE/Licensing /app/FRE_Licensing
ADD ./LicensingSettings_ls.xml /app/FRE_Licensing/LicensingSettings.xml
WORKDIR /app/FRE_Licensing
# 安裝授權服務
COPY ./DeployLS.ps1 /app/DeployLS.ps1
EXPOSE 3022
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENTRYPOINT /app/DeployLS.ps1
LicensingSettings_ls.xml
<?xml version="1.0" encoding="utf-8"?>
<LicensingSettings xmlns="http://www.abbyy.com/Protection/LicensingSettings">
  <LocalLicenseServer>
    <ConnectionProtocol ProtocolType="TCP/IP" />
  </LocalLicenseServer>
</LicensingSettings>
echo "Preparing logging folder:"
$folder = "C:\ProgramData\ABBYY\SDK\12\Licenses"
echo $folder
if( (Test-Path -Path $folder) -ne $True ) {
    New-Item -Path $folder -ItemType Directory
}
echo "LicensingSettings.xml found:"
cd "C:/app/FRE_Licensing"
type LicensingSettings.xml
echo "Starting license service..."
.\LicensingService.exe /standalone
 
echo "License service stopped."
return 500
Dockerfile_worker
FROM mcr.microsoft.com/windows/servercore:ltsc2019 as fre12installation
# 將擷取出的程式庫複製到 C:/app/FRE12 資料夾
ARG library_src="./FRE/FineReader Engine"
ADD $library_src /app/FRE12
ADD ./LicensingSettings_worker.xml /app/FRE12/Bin64/LicensingSettings.xml
# 取代 worker LicensingSetting.xml 中的 <service_address>
ARG service_address
COPY ./SetUpWorkerLicensing.ps1 /app/SetUpWorkerLicensing.ps1
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN /app/SetUpWorkerLicensing.ps1 -ServerAddress $service_address
# 複製並執行測試應用程式
COPY ./TestAppFolder /app/TestAppFolder
COPY ./RunTestApp.ps1 /app/RunTestApp.ps1
CMD /app/RunTestApp.ps1
LicensingSettings_worker.xml
<?xml version="1.0" encoding="utf-8"?>
<LicensingSettings xmlns="http://www.abbyy.com/Protection/LicensingSettings">
  <LicensingServers>
    <MainNetworkLicenseServer ServerAddress="<server_address>" ProtocolType="TCP/IP" />
  </LicensingServers>
</LicensingSettings>
Param (
[string]$service_address
)
# 用於準備客戶端授權記錄資料夾,並在 LicesingSettings.xml 中設定 ServerAddress 的指令碼
echo "Preparing logging folder:"
echo "C:\ProgramData\ABBYY\SDK\12\Licenses"
New-Item -Path "C:\ProgramData\ABBYY\SDK\12\Licenses" -ItemType Directory
echo "LicensingSettings.xml found:"
cd "C:/app/FRE12/Bin64"
type LicensingSettings.xml
echo "Setting service address to: "
echo $service_address
((Get-Content -path LicensingSettings.xml -Raw) -replace '<server_address>',$Env:service_address) `
| Set-Content -Path LicensingSettings.xml
echo "LicensingSettings.xml was set:"
type LicensingSettings.xml
# 用於從 TestAppFolder 資料夾執行測試應用程式的指令碼
# 使用引數啟動測試應用程式(CommandLineInterface.exe 用作測試應用程式)
cd C:\app\TestAppFolder
.\CommandLineInterface.exe  -pi -if Demo.tif -f PDF -of Demo.pdf
# 若要在 Docker 容器中使用 CommandLineInterface 程式碼範例,您需要:
# 1)在 SamplesConfig.h 中指定 Docker 容器的資料:
# - GetLicensePath、GetCustomerProjectId、GetLicensePassword
# - 將 L"C:\\app\\FRE12\\Bin64\\FREngine.dll" 指定為 GetFreDllPath
# 2)以 x64 組態重新建置專案。
# 3)將 CommandLineInterface.exe、*.ABBYY.ActivationToken 授權檔
#  以及示範影像(Demo.tif)複製到 \TestAppFolder 資料夾中。

另請參閱

在 Windows 上安裝授權服務 授權 啟用