Build from Source
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
If you prefer to build PreviewProxy yourself rather than use the Docker image, follow these steps.
Prerequisites
Section titled “Prerequisites”| Dependency | Required for | Notes |
|---|---|---|
| Rust (stable) | Core build | Install via rustup |
| pkg-config | Linking system libraries | Install via your system package manager |
| cmake | JPEG XL build (jpegxl-sys) | Install via your system package manager |
| nasm | AVIF encoding (rav1e) | Install via your system package manager |
| libheif | HEIC input support | Install via your system package manager |
| pdfium | PDF input support | Optional - download from pdfium-binaries |
| ffmpeg | Video thumbnail extraction | Optional - must be on PATH or set via PP_FFMPEG_PATH |
Installing build dependencies
Section titled “Installing build dependencies”# Debian/Ubuntusudo apt install build-essential pkg-config cmake nasm libheif-dev ffmpeg
# macOS (Homebrew)brew install pkgconf cmake nasm libheif ffmpeg
# Arch Linuxsudo pacman -S pkgconf cmake nasm libheif ffmpegWindows - requires Visual Studio Build Tools and vcpkg. Run in a Developer PowerShell:
choco install pkgconfiglite -yvcpkg install dav1d libjxl libheif --triplet x64-windows-static-mdThen set these environment variables before building:
$env:VCPKG_ROOT = "C:\vcpkg"$env:PKG_CONFIG_PATH = "C:\vcpkg\installed\x64-windows-static-md\lib\pkgconfig"Installing pdfium
Section titled “Installing pdfium”pdfium does not have official package manager distributions. Download the prebuilt binary for your platform from the pdfium-binaries project and place the shared library where the linker can find it.
# Example for Linux x86_64curl -L https://github.com/bblanchon/pdfium-binaries/releases/latest/download/pdfium-linux-x64.tgz | tar xzsudo cp lib/libpdfium.so /usr/local/lib/sudo ldconfig# Example for macOS (Apple Silicon)curl -L https://github.com/bblanchon/pdfium-binaries/releases/latest/download/pdfium-mac-arm64.tgz | tar xzsudo cp lib/libpdfium.dylib /usr/local/lib/# Example for Windows x86_64curl -L https://github.com/bblanchon/pdfium-binaries/releases/latest/download/pdfium-win-x64.tgz | tar xzcopy bin\pdfium.dll C:\Windows\System32\Clone the repository and build in release mode:
git clone https://github.com/ViGrise/previewproxy.gitcd previewproxycargo build --releaseThe compiled binary will be placed at:
./target/release/previewproxy./target/release/previewproxy servePreviewProxy will start and listen on port 8080.
CLI Flags
Section titled “CLI Flags”Every configuration option can be provided either as an environment variable or as a CLI flag. Flags take precedence over environment variables.
| Environment Variable | CLI Flag | Description |
|---|---|---|
| PP_PORT | --port | Server listen port |
| PP_APP_ENV | --env | Environment (development or production) |
| PP_HMAC_KEY | --hmac-key | HMAC-SHA256 signing key |
| PP_ALLOWED_HOSTS | --allowed-hosts | Comma-separated allowed upstream hostnames |
| PP_CACHE_DIR | --cache-dir | L2 disk cache directory |
| PP_FFMPEG_PATH | --ffmpeg-path | Path to the ffmpeg binary |
For the full list of flags, run:
./target/release/previewproxy serve --help