battle-snake / battle_snake

AI Programing Competition Game Server
GNU Affero General Public License v3.0
12 stars 11 forks source link

Game JS Compilation in Docker Image failed. #27

Closed jrstarke closed 6 years ago

jrstarke commented 6 years ago

When running the docker image, if you attempt to start a game, the browser appears blank. Looking at the browser console, there is the following exception:

Uncaught Error: Module build failed: Error: Compiler process exited with error Compilation failed
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn /app/assets/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make ENOENT
    at exports._errnoException (util.js:1018:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:505:3

    at ChildProcess.<anonymous> (/app/assets/node_modules/node-elm-compiler/index.js:141:27)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Socket.<anonymous> (internal/child_process.js:342:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:497:12)
    at exports._errnoException (util.js:1018:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:505:3

    at ChildProcess.<anonymous> (/app/assets/node_modules/node-elm-compiler/index.js:141:27)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Socket.<anonymous> (internal/child_process.js:342:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:497:12)
    at Object.xPM0 (http://localhost:3000/js/game-76287735d82777240a5dd816d6e6bd40.js?vsn=d:542:7)
    at __webpack_require__ (http://localhost:3000/js/runtime-da1006a2c5fac21760970c5be580bab2.js?vsn=d:55:30)
    at Object.7RBF (http://localhost:3000/js/game-76287735d82777240a5dd816d6e6bd40.js?vsn=d:257:67)
    at __webpack_require__ (http://localhost:3000/js/runtime-da1006a2c5fac21760970c5be580bab2.js?vsn=d:55:30)
    at webpackJsonpCallback (http://localhost:3000/js/runtime-da1006a2c5fac21760970c5be580bab2.js?vsn=d:26:23)
    at http://localhost:3000/js/game-76287735d82777240a5dd816d6e6bd40.js?vsn=d:1:1

Looking into the docker image, the following throw is found in /root/prod/lib/bs/priv/static/js/game-76287735d82777240a5dd816d6e6bd40.js source code.


throw new Error("Module build failed: Error: Compiler process exited with error Compilation failed\nevents.js:160\n      throw er; // Unhandled 'error' event\n      ^\n\nError: spawn /app/assets/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make ENOENT\n    at exports._errnoException (util.js:1018:11)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)\n    at onErrorNT (internal/child_process.js:367:16)\n    at _combinedTickCallback (internal/process/next_tick.js:80:11)\n    at process._tickCallback (internal/process/next_tick.js:104:9)\n    at Module.runMain (module.js:606:11)\n    at run (bootstrap_node.js:390:7)\n    at startup (bootstrap_node.js:150:9)\n    at bootstrap_node.js:505:3\n\n    at ChildProcess.<anonymous> (/app/assets/node_modules/node-elm-compiler/index.js:141:27)\n    at emitTwo (events.js:106:13)\n    at ChildProcess.emit (events.js:191:7)\n    at maybeClose (internal/child_process.js:886:16)\n    at Socket.<anonymous> (internal/child_process.js:342:11)\n    at emitOne (events.js:96:13)\n    at Socket.emit (events.js:188:7)\n    at Pipe._handle.close [as _onclose] (net.js:497:12)");```
Dkendal commented 6 years ago

I'm not able to replicate this, can you specify what docker image you're running?

As an aside, webpack compilation should not be happening inside the docker image if you are pulling from docker hub, are you building the image locally?

Dkendal commented 6 years ago

To clarify a bit: the docker image is not intended for developing the elixir project itself, as it produces a full production release, it is intended to be run locally to develop competition snakes against. Perhaps that wasn’t clear in the documentation.

If you wish to develop against a development build of the server then I would recommend checking out https://github.com/battle-snake/battle_snake#compiling-from-source

Docker output should look like:

 > docker run -it -P --add-host="localhost:192.168.0.137" battlesnake/battle_snake:latest
pre start hook...
20:51:46.852 [info] Loaded [bs] app
20:51:46.856 [info] Started [logger] app
20:51:46.856 [info] Running on node [bs@127.0.0.1]
20:51:46.856 [info] =====================================================
20:51:46.856 [info] Storage Up Task
20:51:46.856 [info] -----------------------------------------------------
20:51:46.856 [info] Creating schema on bs@127.0.0.1
20:51:46.939 [info] Schema already exists
20:51:46.939 [info] Done
20:51:51.227 [info] Loaded [bs] app
20:51:51.230 [info] Started [logger] app
20:51:51.230 [info] Running on node [bs@127.0.0.1]
20:51:51.230 [info] =====================================================
20:51:51.230 [info] Migrate Task...
20:51:51.230 [info] -----------------------------------------------------
20:51:51.230 [info] Booting dependencies...
20:51:51.375 [info] [ecto_mnesia] config: [host: :"bs@127.0.0.1", storage_type: :disc_copies]
20:51:51.375 [info] Running migrations for [BsRepo]
20:51:51.375 [info] Starting repos..
20:51:51.380 [info] Running migrations for bs
20:51:51.386 [info] Migrations path: ./lib/bs-5.0.0/priv/bs_repo/migrations
20:51:51.386 [info] Repo config: [host: :"bs@127.0.0.1", storage_type: :disc_copies]
20:51:51.412 [info] Already up
20:51:51.412 [info] Done
Exec: /app/_build/prod/rel/bs/erts-9.2/bin/erlexec -noshell -noinput +Bd -boot /app/_build/prod/rel/bs/releases/5.0.0/bs -boot_var ERTS_LIB_DIR /app/_build/prod/rel/bs/erts-9.2/../lib -env ERL_LIBS /app/_build/prod/rel/bs/lib -pa /app/_build/prod/rel/bs/lib/bs-5.0.0/consolidated -args_file /app/_build/prod/rel/bs/var/vm.args -config /app/_build/prod/rel/bs/var/sys.config -mode embedded -extra --
Root: /app/_build/prod/rel/bs
20:51:53.182 [info] Running BsWeb.Endpoint with Cowboy using http://0.0.0.0:3000
post start hook...
20:53:41.049 request_id=3cdp82fh4c7j6nhdj9qoca96oi1plb9g [info] GET /
20:53:41.050 request_id=3cdp82fh4c7j6nhdj9qoca96oi1plb9g [info] Sent 200 in 1000µs
20:53:45.103 request_id=peu8680siu4oh60gre47ppe8i42indhf [info] GET /new
jrstarke commented 6 years ago

Strange that you're not able to replicate this. I can replicate it perfectly.

I get the JavaScript Console error mentioned above by running docker run -it -p 3000:3000 battlesnake/battle_snake, creating a new came, and passing it one of my previous snakes (which is still live), then clicking Show.

Further, if I run docker run -it -p 3000:3000 battlesnake/battle_snake cat /root/prod/lib/bs/priv/static/js/game-76287735d82777240a5dd816d6e6bd40.js | grep "Compilation" you can see that the Error message mentioned above is actually compiled into the JS in the Docker image.

Hope that helps.