Sign inSign up

czqclm/fast-package-electron

By czqclm

•Updated about 3 years ago

Don't worry about various issues, quickly build your Electron application.

Image
0

249

czqclm/fast-package-electron repository overview

Since Electron has strict environmental requirements, including but not limited to node version, npm version, and dependencies on wine and wine64, upgrading and migrating become very difficult.

Runtime environment requirements: Docker.

⁠Building Images

Please go to a machine with a better network environment, such as an overseas VPS server, to build images, as errors may occur when packaging in China (mainly due to dependencies on wine and Electron). If you don't want to build it yourself, please see the "Executing Packaging" section, where you can use the "czqclm/fast-package-electron:22-wine" image I have built.

Project Address: https://github.com/czqclm/fast-package-electron⁠

Pull the project files.

git clone https://github.com/czqclm/fast-package-electron

Execute a local image build.

docker build -t fast-package-electron:22-wine . 

⁠Executing Packaging

Go to the directory where you want to package (with "index.html" at the same level), and execute the following command. Replace $(pwd) with the directory you want to package, such as /root/project.

docker run --rm --name my_container \
-v $(pwd):/project \
fast-package-electron:22-wine \
/bin/sh -c "cp -r /package_lib/node_modules /project && cd /project && npm run package_win64"

If packaging is successful, you can find the desired files in the "app-win32-x64" directory.

Of course, you can use the image I have packaged.

Docker Hub: https://hub.docker.com/r/czqclm/fast-package-electron⁠

docker run --rm --name my_container \
-v $(pwd):/project \
czqclm/fast-package-electron:22-wine \
/bin/sh -c "cp -r /package_lib/node_modules /project && cd /project && npm run package_win64"

package.json example

{
  "name": "start",
  "version": "1.0.0",
  "description": "Fast package elertron.",
  "main": "electron_main.js",
  "scripts": {
    "package_win64": "electron-packager ./ --out . --platform=win32  --arch=x64 --icon=./icon/logo.ico",
    "package_win32": "electron-packager ./ --out . --platform=win32  --arch=ia32 --icon=./icon/logo.ico",
    "start": "electron ."
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "electron": "^22.3.15"
  },
  "dependencies": {
    "electron-packager": "^17.1.1"
  }
}

⁠建议使用22-win标签,因为它支持win7和win32 win64。

因 Eletron 对环境要求十分苛刻,包括但不限于 node 版本、npm 版本、wine wine64 的依赖,导致升级与迁移十分困难。

运行环境要求:Docker

⁠构建镜像

构建镜像这一步请一定前往网络环境较好的机器上执行,辟如海外 vps 等,国内打包容易发生错误(主要是 wine 与 electron 的依赖) 如不想自己构建,请看 执行打包 部分,可以用我构建好的 czqclm/fast-package-electron:25-wine64

项目地址: https://github.com/czqclm/fast-package-electron⁠ 拉取项目文件

git clone https://github.com/czqclm/fast-package-electron

执行本地构建镜像

docker build -t fast-package-electron:22-wine  . 

⁠执行打包

前往需要打包的目录下(index.html 同级目录),执行命令。或者将 $(pwd) 替换为你需要打包的目录,辟如:/root/project

docker run --rm --name my_container \
-v $(pwd):/project \
fast-package-electron:22-wine  \
/bin/sh -c "cp -r /package_lib/node_modules /project && cd /project && npm run package_win64"

如果打包没有问题即可在 app-win32-x64 目录下找到你想要的文件了

当然你可以用我打包好的镜像 docker hub: https://hub.docker.com/r/czqclm/fast-package-electron⁠

docker run --rm --name my_container \
-v $(pwd):/project \
czqclm/fast-package-electron:22-wine  \
/bin/sh -c "cp -r /package_lib/node_modules /project && cd /project && npm run package_win64"

package.json 示例

{
  "name": "start",
  "version": "1.0.0",
  "description": "Fast package elertron.",
  "main": "electron_main.js",
  "scripts": {
    "package_win64": "electron-packager ./ --out . --platform=win32  --arch=x64 --icon=./icon/logo.ico",
    "package_win32": "electron-packager ./ --out . --platform=win32  --arch=ia32 --icon=./icon/logo.ico",
    "start": "electron ."
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "electron": "^22.3.15"
  },
  "dependencies": {
    "electron-packager": "^17.1.1"
  }
}

Tag summary

Content type

Image

Digest

sha256:d560006c5…

Size

2.2 GB

Last updated

about 3 years ago

docker pull czqclm/fast-package-electron:22-wine