Successfully Run Cocos Creator on Linux and released it as docker image

Successfully Run Cocos Creator on Linux and released it as docker image
0.0 0

#1

Since Cocos Creator is an electron app, I thought it should be easy to run it on Linux. As a result, successfully launched Cocos Creator app on Ubuntu.

To make it possible,

  • clone electron tag 1.7.5 which is the version cocos creator uses. Modify atom/common/asar/archive.cc, atom/browser/net/url_request_asar_job.cc and lib/common/asar.js files to decrypt js files and asar header. You can find correct asar.js file from Cocos Creator itself by opening developer tools and find the file ELECTRON_ASAR.js. Finally build the electron by using ./script/create-dist.py

  • Copy Resources folder from Mac version of Cocos Creator to resources folder of the newly built app.

  • Change node native libraries from mac versions to linux versions. The files are located under resources/app.asar-unpacked/

  • That’s it.

Why I did this because I need a docker image to build the game on CI. You can use sercand/cocos-creator:1.8.0-web image to build your game for web. An example .gitlab-ci.yml configuration which we use build game on Kubernetes:

stages:
  - build
thegame:
  stage: build
  image: sercand/cocos-creator:1.8.0-web
  script:
    - sh /opt/cocos-build.sh --path . --build "platform=web-mobile"
    - aws s3 sync ./build/web-mobile s3://$AWS_BUCKET/testing/$CI_COMMIT_SHA
  tags:
    - kubernetes
  artifacts:
    paths:
    - build/web-mobile

I hope it helps who wants to build their game on ci on each commit. I am currently working on a webpack based library to build cocos-creator projects without using 1.2 GB docker images.


Poll: Why do you want a Linux version of Cocos Creator?
#2

Wow, thanks for sharing!


#3

How do you modify .cc files ?

Modify atom/common/asar/archive.cc, atom/browser/net/url_request_asar_job.cc and lib/common/asar.js files to decrypt js files and asar header. You can find correct asar.js file from Cocos Creator itself by opening developer tools and find the file ELECTRON_ASAR.js.


#4

Nice! Thank you so much for sharing this :slight_smile:


#5

Wow that’s nice!

If this is possible I wonder why the CC team has not made an official Linux release.


#6

@gabdab You need to clone http://github.com/electron/electron and build yourself.
@phero_constructs It is their choice not to release a Linux version. Technically, they built Cocos Creator with electron which is a multi-platform app development tool.


#7

I am on Linux .
Just mounted creator .dmg subpackage 5 - disk image(Apple_HFS:5) with no luck .
I guess you need a Mac to perform the operation you kindly suggested .


#8

You can download the image on docker hub:

docker pull sercand/cocos-creator:1.8.0-web && docker save sercand/cocos-creator:1.8.0-web -o cc.tar

Now you have Cocos Creator in f5bf75745797e61ad02.../layer.tar file, extract it again. By the way, it is missing some files in order to reduce image size, like resources/cocos2d-x folder.


#9

Succesfully pulled !
I am compiling a newer version of libvips (which is v. 8.2.2 on Ubuntu 16.04, 8.4.2 needed)


#10

Succesfully launched , created new project , opening new project gives error , need to check it yet:

[27776] Initializing project /tmp/NewProject
Profile profile://local/local.json warning: reset profile field: last-edit
[27776] Loading packages
[27776] Watching packages
[27776] Run Application
[27776] preview server running at http://localhost:7456
init QuickCompiler: 21.889ms
no valid user ID
[27776] Error: Window “main” crashed: [object Object]
at WebContents.Window.nativeWin.webContents.on.e (/media/gabriele/ee238924-2890-41d2-883b-ddcf3c07ce10/Lavoro/Lavoro_1/cocos2dx/cocos-creator/cc/e48b079e2a22be7fc7b8ad825fd9980ecdc2331210cc09a5b2bb47d4f02f32c1/opt/cocos-creator/resources/app.asar/editor-framework/lib/main/window.js:1:2853)
at emitTwo (events.js:106:13)
at WebContents.emit (events.js:194:7)


#11

@gabdab start your project with: cocos-creator --path $YOUR_PROJECT_PATH
At the MacOSX you will see following ugly scene. There are two cocosCreator icon
15

First one is Dashboard and second one is project. Opening second cocos-cretor is the reason of crash.


#12

Yes , working now

.
It launchs right away , no taskbar icons showing on Ubuntu.
Great job, many thanks .
P.S: I can set up a docker image if needed, just ask.


#13

This is cool. We don’t release a Linux version because supporting another platform adds several layers of complexity for us. We don’t feel we have the resources to do this at this time.


#14

hi, thanks for sharing. Can you describe these steps in details?


#15

This is so amazing @sercand, thank you again for sharing!

I think it’s enough that we can have a linux CI build the game, the actual development could be done in win/mac. Doesn’t need to be supported by linux.

@sercand would it be possible to push a 1.8.1 version of your docker container to dockerhub?

Thank you!


#16

@sercand

I pulled creator form docker and try run my project, but I get error:

[17728] Initializing project /home/dmitriy/programming/games/fabulous-slots
[17728] Loading packages
[17728] Watching packages
[17728] Run Application
Uncaught Exception: Error: libvips-cpp.so.42: cannot open shared object file: No such file or directory
at process.module.(anonymous function) (ELECTRON_ASAR.js:191:20)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:191:20)
at Object.Module._extensions…node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:191:20)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/home/dmitriy/programming/tools/ide/cocos-creator/resources/utils/sharp/lib/constructor.js:8:15)
[17728] Error: Error: libvips-cpp.so.42: cannot open shared object file: No such file or directory
at process.module.(anonymous function) (ELECTRON_ASAR.js:191:20)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:191:20)
at Object.Module._extensions…node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:191:20)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/home/dmitriy/programming/tools/ide/cocos-creator/resources/utils/sharp/lib/constructor.js:8:15)
at process.on.t (/home/dmitriy/programming/tools/ide/cocos-creator/resources/app.asar/editor/core/editor-init.js:1:1068)
at emitOne (events.js:101:20)
at process.emit (events.js:191:7)
at process._fatalException (bootstrap_node.js:308:26)
no valid client ID


#17

@Ronsku I just pushed version 1.9.0 and 1.8.1 to docker hub.


#18

@limetris I guess libvips library missing in your machine. By the way, you can download cocos-creator version 1.9 at https://goo.gl/p5KSAz .


#19

Yes, I installed this library and it works.

Thank you very much for 1.9 version and link without docker!!! ))


#20

I still hope the developers will take pity on us and will post a version for Linux. An unofficial link here or elsewhere will be more than enough. And it will save your time.