Building & running headless unity3D game in ubuntu docker container

Viewed 2264

I was trying to find a way how to build and run my game from a Ubunty-based linux container just using command line. Even though I was able to find few containers on DockerHub, neither of them allowed me to pass license registration stage in 'batch' mode.

https://hub.docker.com/r/eamonwoortman/unity3d/~/dockerfile/ https://hub.docker.com/r/chenjr0719/ubuntu-unity-novnc/

Commands I tried so far:

xvfb-run --auto-servernum /opt/Unity/Editor/Unity -force-free -batchmode -nographics -logFile -username 'xxx' -password xxx -quit

/opt/Unity/Editor/Unity -force-free -batchmode -nographics -logFile -username 'xxx' -password xxx -quit

I'm usually getting following error log from Unity:

mono profile = '/opt/Unity/Editor/Data/Mono/lib/mono/2.0' Initialize mono Mono path[0] = '/opt/Unity/Editor/Data/Managed' Mono path[1] = '/opt/Unity/Editor/Data/Mono/lib/mono/2.0' Mono path[2] = '/opt/Unity/Editor/Data/UnityScript' Mono path[3] = '/opt/Unity/Editor/Data/Mono/lib/mono/2.0' Mono config path = '/opt/Unity/Editor/Data/Mono/etc' Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,defer=y,address=0.0.0.0:56542 DisplayProgressbar: Unity license Cancelling DisplayDialog: Failed to activate/update license. Timeout occured while trying to update license. Please try again later or contact support@unity3d.com This should not be called in batch mode.

I wonder is someone else had already solved that problem and able to share Dockerfile & proper command lines.

1 Answers

It has been quite a while since the original question, but it took me a lot of time to find the correct answer, so just in case someone else would struggle with this problem - the answer is:

At some point Unity stopped requiring usage of xvfb-run and neatly builds stuff without it. If using xvfb-run - you'll be receiving timeouts (Unity error messages are pretty misleading in this case). I have a pipeline on Jenkins that uses Ubuntu image and these commands work fine for me so far

The trick is in using "-nographics" argument after implementation of which the need in xvfb-run disappeared.

Activate

/opt/unity/Editor/Unity -quit -logFile -batchmode -nographics -username XXXX -password XXXX -serial XXXX

Build

/opt/unity/Editor/Unity -quit -logFile -batchmode -nographics -quit -projectPath . -buildTarget iOS -customBuildTarget iOS -customBuildName XXXX -customBuildPath builds/iOS/ -executeMethod BuildCommand.PerformBuild -logFile /dev/stdout

Return license

/opt/unity/Editor/Unity -quit -logFile -batchmode -nographics -username XXXX -password XXXX -serial XXXX

Hope this saves someone that huge amount of time I wasted on figuring this out ;)

Related