Access to localhost when building Extender Docker image

Following the Running on Docker instructions at https://github.com/defold/extender/blob/dev/README.md, build.sh fails at step 5. This is on MacOS.

=>ERROR [ 5/43] RUN wget -q -O - http://localhost:9999/clang%2Bllvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz | tar xJ -C /usr/local --strip-components=1 145.2s
[ 5/43] RUN wget -q -O - http://localhost:9999/clang%2Bllvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz | tar xJ -C /usr/local --strip-components=1:
#8 145.2 xz: (stdin): File format not recognized

If I run the wget command outside of the context of Docker, it’s fine. I’m not familiar with Docker but is there some kind of additional setup needed to allow Docker to access the web server running at localhost:9999 ?

Hi!

I’m not a ware of such limitations.

Please be aware that building the docker container isn’t likely to work on an arm64 macOS, even under Rosetta. We ourselves use an intel Mac to build the container.

Also, for macOS, we have now moved away from a Docker container altogether, since it became to burdensome to keep up with Apples changes to formats etc.
We now use the scripts for the “standalone” server when it comes to building for the macOS Server.
So, depending on your needs, you may now edit: have no need to build a Docker container.

I think what Mathias meant to say is “you may NOT need to build a Docker container” :slight_smile:

I use the “rebuild-and-run-standalone-local.sh” script to build and then run a server on my M1 Mac:

Note that this script will only be able to build for iOS and macOS. It should be possible to expand its use and get it to build Android and other platforms as long as you have the required SDKs installed and set the environment variables specified in Dockerfile.

1 Like

I started with that as it did look simpler, but it uses scripts in a git submodule (aws-build-tools) which isn’t public, and a previous discussion steered me towards the Docker approach.

1 Like

Looking at the code, we’ve also (recently) remove the iOS/macOS support from the Docker container (since we no longer needed it!).

So, I guess we need to look into why the standalone builds require any of our private aws scripts :thinking:

1 Like

Oh, yes, we have a ticket for that: https://github.com/defold/extender/issues/255

I’ll take a look at this tomorrow since I’m deep in extender work this week anyway.

1 Like

I saw that this issue was closed over the weekend (thanks @britzl) and I made some progress using rebuild-and-run-standalone-local.sh but I’m not quite there yet.

Building the extender initially showed a 404 in the output of the python http server as it was looking for
XcodeDefault14.2.xctoolchain.darwin.tar.gz
whereas package_xcode_and_sdks.sh produces
XcodeDefault.xctoolchain.darwin.tar.gz
which was obviously just a simple rename to fix.

Trying to then build with Bob (macos target) leads to errors:

ERROR: cjson/ext.manifest:1: 'library not found for -lclang_rt.osx'
ERROR: cjson/ext.manifest:1: 'Missing library 'clang_rt.osx''

I can see libclang_rt.osx.a located within XcodeDefault14.2.xctoolchain at /usr/lib/clang/14.0.0/lib/darwin - assuming that’s the file it’s looking for, is there any way I can find out where it’s looking / why it’s not being found?

1 Like

The libclang_rt.osx.a is part of the Xcode command line tools (XcodeDefault14.2.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.osx.a) , and should have been packaged by the script. Are you certain it is part of your package?

which was obviously just a simple rename to fix.

This isn’t right. The script should output XcodeDefault14.2.xctoolchain.darwin.tar.gz.

Also, the version numbers matter, as there are version numbers inside the package (as shown in the clang_osx path above). Renaming a Xcode 13 to an Xcode 14 won’t work.

I suspect you are trying to bundle from an incompatible (older) Xcode?

1 Like

Yes, if I decompress the package then I confirm it’s present inside:

dri@dris-mbp XcodeDefault.xctoolchain % ls -l usr/lib/clang/14.0.0/lib/darwin/libclang_rt.osx.a
-rw-r--r--  1 dri  staff  535304 18 Oct  2022 usr/lib/clang/14.0.0/lib/darwin/libclang_rt.osx.a

Before I started, I had the latest Xcode 14.3, which I deleted, and then downloaded 14.2 from https://developer.apple.com/download/all/?q=xcode

Might’ve resolved this - there were Xcode build tools at /usr/bin that seemed to be confusing things, which I resolved with xcode-select

1 Like

But here’s a question - how do I prevent Bob from using a cached engine, and force a new engine build?

I’m glad you resolved the issue!

To force a new build, I remove the cache like so:

rm -rf .internal/cache
3 Likes

The standalone macOS Server is working great but it would be useful to build for Windows too so I went back to Docker.

Following the instructions in README.md, and running on Windows 10, I have:

  • Forked the dev branch of defold/extender
  • Packaged up required tools & SDKs
  • Uploaded them to a web server (serving them with a local Python server showed occasional errors)
  • Modified the dockerfile to remove references to Emscripten, Switch and PS4
  • Opened Git Bash (as mentioned in the readme) and specified DM_PACKAGES_URL to point at the web server
  • Built the Docker image using build.sh -xtest
  • Run the image with run-local.sh
  • Verified that the extender exists by connecting to localhost:9000 from Chrome, which outputs:

Extender
4a7839d
2023-05-04 10:44:02

If I build without -xtest then some tests fail, but from first glance perhaps they’re not designed to run on Windows.

Then I tried building extension-spine from the editor, as it’s a small project with a native extension, and got this output:
“Failed: Connection reset”

And then Bob (in a Windows Command Prompt):

java -jar d:\Installs\Defold_1.4.5\bob.jar resolve build --archive bundle --build-server http://localhost:9000
Download archive(s)Downloading 0 archive(s)
Working...Reading classes... 1% ...done!
Build Remote Engine...
Building engine...ERROR: unspecified:-1: 'com.dynamo.bob.CompileExceptionError: 'x86_64-win32' could not be built. Sdk version: '3dbbf1dbebd3a8146f6a917d101882a61f56afdc'
Log: '<failed reading log>''

'x86_64-win32' could not be built. Sdk version: '3dbbf1dbebd3a8146f6a917d101882a61f56afdc'
Log: '<failed reading log>'
Cause: java.net.SocketException: Connection reset

I noticed that I can’t connect with curl either:

curl http://localhost:9000
curl: (56) Recv failure: Connection was reset

Docker adds a few lines to the hosts file, and I’ve tried both the IP address and host.docker.internal without success
# Added by Docker Desktop
192.168.86.37 host.docker.internal
192.168.86.37 gateway.docker.internal

Any suggestions on what I could try next?

You can run the regular Docker container on either Linux, Windows or macOS.
The Docker container runs Ubuntu, and it can build for Windows targets as well (win32/Win64).

Run the server with the bat file: server/scripts/run-local.bat

When you have the extender server running, you can access it using http(s) like so: https://build.defold.com
Or via your local server: http://localhost:9000

Have you verified that you can access it on that address/port?

What does the server log say in the terminal when you launched it? Did it start ok?

I mentioned above that I can access http://localhost:9000 from Chrome but not from curl.
Was previously using run-local.sh from Git Bash.
run-local.bat from a command prompt behaves the same.
Server output when launching:$ ./server/scripts/run-local.sh

Using local env:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.6)

2023-05-04 12:15:00.688 - INFO 7 --- [           main] com.defold.extender.ExtenderApplication  : Starting ExtenderApplication using Java 11.0.18 on 05a9e61c2494 with PID 7 (/app.jar started by extender in /)
2023-05-04 12:15:00.695 - INFO 7 --- [           main] com.defold.extender.ExtenderApplication  : The following 1 profile is active: "dev"
2023-05-04 12:15:04.238 - INFO 7 --- [           main] org.eclipse.jetty.util.log               : Logging initialized @6762ms to org.eclipse.jetty.util.log.Slf4jLog
2023-05-04 12:15:04.656 - INFO 7 --- [           main] o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 9000
2023-05-04 12:15:04.659 - INFO 7 --- [           main] org.eclipse.jetty.server.Server          : jetty-9.4.45.v20220203; built: 2022-02-03T09:14:34.105Z; git: 4a0c91c0be53805e3fcffdcdcc9587d5301863db; jvm 11.0.18+10-post-Ubuntu-0ubuntu120.04.1
2023-05-04 12:15:04.727 - INFO 7 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring embedded WebApplicationContext
2023-05-04 12:15:04.728 - INFO 7 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3870 ms
2023-05-04 12:15:05.200 - INFO 7 --- [           main] org.eclipse.jetty.server.session         : DefaultSessionIdManager workerName=node0
2023-05-04 12:15:05.200 - INFO 7 --- [           main] org.eclipse.jetty.server.session         : No SessionScavenger set, using defaults
2023-05-04 12:15:05.202 - INFO 7 --- [           main] org.eclipse.jetty.server.session         : node0 Scavenging every 600000ms
2023-05-04 12:15:05.210 - INFO 7 --- [           main] o.e.jetty.server.handler.ContextHandler  : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@3e14c16d{application,/,[file:///tmp/jetty-docbase.9000.5148517514322438762/],AVAILABLE}
2023-05-04 12:15:05.211 - INFO 7 --- [           main] org.eclipse.jetty.server.Server          : Started @7736ms
2023-05-04 12:15:05.230 - INFO 7 --- [           main] c.d.extender.services.DefoldSdkService   : SDK service using directory /var/extender/sdk with cache size 10
2023-05-04 12:15:05.242 - INFO 7 --- [           main] c.d.extender.cache.DataCacheFactory      : Creating local disk cache in directory /var/extender/cache/data
2023-05-04 12:15:05.250 - INFO 7 --- [           main] c.d.extender.services.GradleService      : GRADLE service using directory /tmp/.gradle with cache size 2048
2023-05-04 12:15:05.255 - INFO 7 --- [           main] c.d.extender.services.CocoaPodsService   : CocoaPodsService service
2023-05-04 12:15:05.471 - INFO 7 --- [           main] c.d.extender.services.UserUpdateService  : UserUpdateService() updateInterval = 900000 usersResource = null
2023-05-04 12:15:05.471 - INFO 7 --- [           main] c.d.extender.services.UserUpdateService  : UserUpdateService - No extender.authentication.users configuration has been set
2023-05-04 12:15:05.797 - INFO 7 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will not secure any request
2023-05-04 12:15:06.353 - INFO 7 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2023-05-04 12:15:06.451 - INFO 7 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-05-04 12:15:06.452 - INFO 7 --- [           main] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-05-04 12:15:06.457 - INFO 7 --- [           main] o.s.web.servlet.DispatcherServlet        : Completed initialization in 5 ms
2023-05-04 12:15:06.500 - INFO 7 --- [           main] o.e.jetty.server.AbstractConnector       : Started ServerConnector@5454d35e{HTTP/1.1, (http/1.1)}{0.0.0.0:9000}
2023-05-04 12:15:06.502 - INFO 7 --- [           main] o.s.b.web.embedded.jetty.JettyWebServer  : Jetty started on port(s) 9000 (http/1.1) with context path '/'
2023-05-04 12:15:06.544 - INFO 7 --- [           main] com.defold.extender.ExtenderApplication  : Started ExtenderApplication in 7.508 seconds (JVM running for 9.07)

Then I don’t know. For me it works, and I don’t think I’ve done anything special.
Could it be firewall related?
I could have suspected Java version or certificate if not curl had also failed :thinking:

I was able to get it running on a different port. Maybe something else is using the default 9000.

2 Likes