Multi Platform Build
Don't expect that you can build an app for all platforms on one platform.
- If your app has native dependencies, they can only be compiled on the target platform unless prebuild is used. Most node modules don't provide prebuilt binaries.
- macOS Code Signing works only on macOS. Cannot be fixed.
For CI workflow examples across all platforms, see GitHub Actions.
macOS
All required system dependencies (except rpm) are downloaded automatically on demand on macOS 10.12+.
To build rpm:
brew install rpm
Linux
You can use Docker to avoid installing system dependencies.
To build in distributable format:
sudo apt-get install --no-install-recommends -y libopenjp2-tools
To build rpm:
sudo apt-get install --no-install-recommends -y rpm
# or
sudo yum install rpm-build
To build pacman:
sudo apt-get install --no-install-recommends -y bsdtar
To build snap (only needed with custom stage packages):
sudo snap install snapcraft --classic
sudo snap install multipass --beta --classic
Build for Windows on Linux
Docker (electronuserland/builder:wine) is recommended to avoid installing system dependencies.
- Install Wine 2.0+ — see WineHQ Binary Packages.
- Install Mono 4.2+ if you want to use Squirrel.Windows (NSIS doesn't require Mono).
Build 32-bit from a 64-bit Machine
sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib
Docker
Build Linux or Windows targets on any platform using Docker.
You cannot build for Windows using Docker if your app has native dependencies that don't use prebuild.
Do not use Docker Toolbox on macOS. Only Docker for Mac works.
Build on a Local Machine
docker run --rm -ti \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
-v ${PWD}:/project \
-v ${PWD##*/}-node-modules:/project/node_modules \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine
Then run yarn && yarn dist inside the container.
If you don't need to build for Windows, use electronuserland/builder — Wine is not included in that image.
Provided Docker Images
Lock your FROM to a specific date-tag (e.g. builder:20-07.23) or digest rather than latest, to prevent unexpected toolset upgrades.
| Image | Contents |
|---|---|
electronuserland/builder or electronuserland/builder:20 | NodeJS 20 + Linux build dependencies. Use for Linux-only targets. |
electronuserland/builder:wine | Wine + NodeJS 20. Use for Windows targets. |
electronuserland/builder:wine-mono | Mono for Squirrel.Windows. |
electronuserland/builder:wine-chrome | google-chrome-stable + xvfb. Use for headless Electron testing. |
electronuserland/builder:base | System dependencies only. Not meant for direct use. |
Images are also tagged with a date suffix -%m.%y (e.g. builder:20-07.23) for pinning. Full build script: build.sh