Cross-Platform Build Process
Relevant source files
The following files were used as context for generating this wiki page:
The cross-platform build process for Duplicator ensures the application can be packaged and distributed across Linux, Windows, and macOS while maintaining a consistent environment that includes an integrated Caddy web server and a PHP runtime. This process leverages electron-builder and custom scripts to manage binary dependencies and platform-specific configurations.
Sources: package.json:1-141, README.md:1-125
Build Pipeline Overview
The build pipeline consists of three primary phases: dependency acquisition, environment preparation, and packaging. The project uses specialized scripts to download required binaries (Caddy and PHP) before triggering the Electron builder.
Dependency Acquisition
Before packaging, the system must fetch platform-specific binaries. This is handled by a set of npm scripts:
npm run download-caddy: Fetches the Caddy executable.npm run download-php: Fetches the PHP runtime.npm run download-all: Executes both downloads simultaneously.
Sources: package.json:12-14, scripts/download-caddy.js
Packaging Workflow
The following diagram illustrates the flow from dependency download to final artifact generation.
The build process triggers dependency downloads before routing to platform-specific packaging logic.
Sources: package.json:10-14, electron-builder-caddy.yml:1-105
Platform-Specific Configurations
The application requires different file handling and runtime settings depending on the target operating system.
Windows Packaging
Windows builds are configured for broad compatibility, including specific fixes for Windows 8.1.
- Targets: NSIS installer, Portable executable, and ZIP archive.
- ASAR: Disabled (
asar: false) to avoid "pattern too long" errors. - Bundled Assets: Includes
php.inispecifically for SQLite extension support on Windows.
Sources: electron-builder-caddy.yml:78-100, WINDOWS-8.1-COMPATIBILITY.md:1-25
Linux Packaging
Linux builds prioritize system integration and footprint reduction.
- Targets: AppImage and DEB.
- PHP Strategy: Unlike Windows, Linux builds use the system's PHP installation. The
php/folder is cleared before building to save space. - Metadata: Includes desktop entry definitions for Categories (Office) and
StartupWMClass.
Sources: electron-builder-caddy.yml:23-53
macOS Packaging
MacOS builds follow Apple's distribution standards.
- Targets: DMG (Disk Image).
- PHP Strategy: Includes a bundled PHP runtime within the
php/directory, which is unpacked from the ASAR for execution.
Sources: electron-builder-caddy.yml:58-76
Build Script Summary
The package.json file defines the command interface for the build system:
| Script Name | Command | Description |
|---|---|---|
build | electron-builder | Standard build using default config |
build:caddy | electron-builder --config electron-builder-caddy.yml | Primary build command for the integrated Caddy version |
download-all | node -e "require('./scripts/download-caddy.js').downloadAll()" | Fetches all external binaries for cross-platform support |
Sources: package.json:10-14
Asset Management and ASAR Configuration
To ensure the Caddy and PHP processes can execute, specific files must be accessible outside the compressed ASAR archive or the ASAR must be disabled entirely.
Selection of packaging strategy based on platform-specific path length and execution requirements.
Sources: electron-builder-caddy.yml:45, 68-76, 85
Important File Paths
| Path | Relevance | Source |
|---|---|---|
caddy/ | Contains the Caddy executable for the local proxy | main-caddy.js:510 |
php/ | Contains PHP binaries (Windows/macOS) | electron-builder-caddy.yml:73, 98 |
app/public/ | The root directory for the Caddy web server | main-caddy.js:683 |
icons/icon.png | The primary application icon used for all platforms | electron-builder-caddy.yml:4-5 |
Sources: electron-builder-caddy.yml:10-21, main-caddy.js:510-683
Deployment and Release
The project utilizes a deployment script (app/deploy-script.sh) to automate version bumping and release tagging.
- Version Update: Increments the patch version in
package.jsonusing Node.js logic. - Git Integration: Commits the version change and creates an annotated tag (e.g.,
v1.5.57). - Distribution: Pushes tags to GitHub, triggering
electron-builder's publish provider.
Sources: app/deploy-script.sh:58-85, package.json:3
Conclusion
The cross-platform build process for Duplicator is a multi-stage workflow that integrates external binary management with Electron packaging. By tailoring the ASAR strategy and PHP runtime requirements to each platform—utilizing system PHP on Linux while bundling it for Windows and macOS—the project maintains high portability and ease of installation.