Skip to main content

Multi Platform Build

info

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.

warning

You cannot build for Windows using Docker if your app has native dependencies that don't use prebuild.

note

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.

tip

If you don't need to build for Windows, use electronuserland/builder — Wine is not included in that image.

Provided Docker Images

tip

Lock your FROM to a specific date-tag (e.g. builder:20-07.23) or digest rather than latest, to prevent unexpected toolset upgrades.

ImageContents
electronuserland/builder or electronuserland/builder:20NodeJS 20 + Linux build dependencies. Use for Linux-only targets.
electronuserland/builder:wineWine + NodeJS 20. Use for Windows targets.
electronuserland/builder:wine-monoMono for Squirrel.Windows.
electronuserland/builder:wine-chromegoogle-chrome-stable + xvfb. Use for headless Electron testing.
electronuserland/builder:baseSystem 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