Linux에서 IronPDF 실행하기: 설정 가이드

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

Linux용 IronPDF 는 약 280MB입니다( IronPDF 코드와 Chrome 브라우저 전체를 포함). Docker 이미지 크기는 약 500MB입니다.

Chrome을 사용하려면 몇 가지 기본 패키지가 필요한데, 이는 사용하는 Linux 배포판에 따라 다릅니다. 대부분의 리눅스 배포판에는 이러한 패키지가 이미 설치되어 있는데, 이는 리눅스의 다양한 애플리케이션과 라이브러리에서 이러한 패키지를 사용하기 때문입니다.

하지만 최소한의 구성만 갖춘 배포판을 사용하는 경우, Linux에서 Chrome을 실행하는 데 필요한 Linux 패키지를 설치해야 합니다.

참고: 디버깅을 쉽게 하려면 다음 설정을 할 수 있습니다.

// Enable detailed debugging for IronPdf
IronPdf.Logging.Logger.EnableDebugging = true;

// Specify the log file path
IronPdf.Logging.Logger.LogFilePath = "Default.log";

// Set the logging mode to capture all log data
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
// Enable detailed debugging for IronPdf
IronPdf.Logging.Logger.EnableDebugging = true;

// Specify the log file path
IronPdf.Logging.Logger.LogFilePath = "Default.log";

// Set the logging mode to capture all log data
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
' Enable detailed debugging for IronPdf
IronPdf.Logging.Logger.EnableDebugging = True

' Specify the log file path
IronPdf.Logging.Logger.LogFilePath = "Default.log"

' Set the logging mode to capture all log data
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All
$vbLabelText   $csharpLabel

더 작은 Docker 이미지를 만드는 방법

1. 실행 시 Install-Package

크기를 줄이는 한 가지 방법은 docker 이미지를 만들 때가 아니라 실행 시에 apt-get 명령을 실행하는 것입니다:

  1. Dockerfile에서 apt-get 명령을 제거합니다.
  2. IronPdf를 초기화하거나 문서를 렌더링하기 전에 Installation.LinuxAndDockerDependenciesAutoConfig = true;를 설정합니다.
  3. 응용 프로그램이 apt-get 명령을 실행할 수 있는 충분한 권한으로 실행되도록 합니다.

참고: 처음 초기화할 때는 apt-get 명령이 완료된 후에야 첫 번째 문서가 렌더링되기 때문에 더 느리며, 이미지를 다시 배포해야 할 때마다 이 프로세스가 반복됩니다.

참고: Install-Package가 성공적으로 완료되었음을 나타내는 콘솔/로그 항목이 표시됩니다.

Executing command 'apt install -y libnss3' in '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  libnspr4
The following NEW packages will be installed:
  libnspr4 libnss3
0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
Executing command 'apt install -y libnss3' in '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  libnspr4
The following NEW packages will be installed:
  libnspr4 libnss3
0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
SHELL

2. IronPdf.Slim을 사용하세요

IronPDF 파일만 포함하고 필요한 파일은 런타임에 다운로드하도록 선택할 수도 있습니다.

  1. 프로젝트에서 IronPDF(및 기타 모든 IronPDF) NuGet 패키지를 제거하고 IronPDF 추가하세요.
  2. IronPdf를 초기화하거나 문서를 렌더링하기 전에 Installation.AutomaticallyDownloadNativeBinaries = true;를 설정합니다.
  3. Dockerfile이 응용 프로그램의 전체 작업 디렉터리에 읽기 및 쓰기 권한을 부여하도록 합니다 (예: RUN chmod +rwx /app/runtimes/linux-x64/native/IronCefSubprocessRUN chmod +rwx /app/로 변경).

참고: 첫 번째 초기화는 NuGet 패키지가 다운로드되고 압축 해제된 후 첫 번째 문서가 렌더링되므로 속도가 느릴 수 있으며, 이 과정은 이미지를 다시 배포할 때마다 반복됩니다.

참고: 다운로드 및 압축 해제가 성공적으로 완료되었음을 나타내는 콘솔/로그 항목이 표시될 것입니다.

Downloading NuGet package from 'https://www.nuget.org/api/v2/package/IronPdf.Native.Chrome.Linux/2023.1.11387'
Extracting package contents '/app/bin/Debug/netcoreapp3.1/IronPdf.Native.Chrome.Linux.2023.1.11387.nupkg/runtimes/linux-x64/native' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Successfully deployed NuGet package 'IronPdf.Native.Chrome.Linux' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Successfully located 'IronInterop' at '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Downloading NuGet package from 'https://www.nuget.org/api/v2/package/IronPdf.Native.Chrome.Linux/2023.1.11387'
Extracting package contents '/app/bin/Debug/netcoreapp3.1/IronPdf.Native.Chrome.Linux.2023.1.11387.nupkg/runtimes/linux-x64/native' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Successfully deployed NuGet package 'IronPdf.Native.Chrome.Linux' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Successfully located 'IronInterop' at '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
SHELL

3. 결론

요약하자면, 초기 컨테이너 크기를 줄이려면 다음과 같이 하면 됩니다.

  • IronPdf.Slim NuGet 패키지를 사용하십시오.
  • IronPDF 설정:
// Set installation options for Linux and Docker environments
Installation.LinuxAndDockerDependenciesAutoConfig = true;
Installation.AutomaticallyDownloadNativeBinaries = true;
// Set installation options for Linux and Docker environments
Installation.LinuxAndDockerDependenciesAutoConfig = true;
Installation.AutomaticallyDownloadNativeBinaries = true;
' Set installation options for Linux and Docker environments
Installation.LinuxAndDockerDependenciesAutoConfig = True
Installation.AutomaticallyDownloadNativeBinaries = True
$vbLabelText   $csharpLabel
  • 애플리케이션 디렉터리에 쓰기/실행 권한이 있는지 확인하십시오.
RUN chmod +rwx /app/

1번과 2번 사항을 모두 활용하는 매우 가벼운 Docker 이미지는 크기를 약 500MB에서 약 200MB로 줄일 수 있습니다.

가능하다면, 간소화된 배포 방식을 선택하지 않는 것이 최상의 성능을 보여줄 것입니다.

일부 컨테이너화된 및 클라우드 환경은 지속적이지 않으며, 따라서 때때로 의존성을 다시 다운로드하거나 apt-get 명령을 다시 실행해야 할 수 있으며 몇 분 정도 소요될 수 있습니다!

하지만 일부 개발자는 배포 용량에 대한 엄격한 요구 사항을 충족해야 할 수도 있다는 점을 이해합니다.

커티스 차우
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다.

시작할 준비 되셨나요?
Nuget 다운로드 18,318,263 | 버전: 2026.4 방금 출시되었습니다
Still Scrolling Icon

아직도 스크롤하고 계신가요?

빠른 증거를 원하시나요? PM > Install-Package IronPdf
샘플을 실행하세요 HTML이 PDF로 변환되는 것을 지켜보세요.