neohabitat: Docker deployment broken
The Docker deployment for NeoHabitat is currently broken. We’ve been trying to troubleshoot it for a month or two now with varying degrees of success.
Relevant info
Relevant issues to our recent work are: #390 #392
Several PR’s were made during this time to update the deployment and get things working again. The first of these commits starts with commit e7c220d.
During this time, we were able to get things operational again and the fork over at https://github.com/AmandaJonesAway/neohabitat successfully works, but somehow with the PR’s that got merged, the master repository is still in a broken state. It should be noted that AmandaJonesAway’s fork is 15 commits behind master if comparing against it.
Setup
Make sure you have the NeoHabitat installer to test with as it contains a copy of VICE, and the Habitat disk images. You can grab a copy here: https://github.com/StuBlad/neohabitat-installer/releases. If you don’t want to use the installer, the disk images are available in the same repository.
Here are the commands I’m using so you can recreate the environment and replicate the broken build.
Ubuntu 22.04 (LTS) x64
Install Docker using the apt repository as per instructions here (https://docs.docker.com/engine/install/ubuntu/)
git clone https://github.com/frandallfarmer/neohabitat.git
cd neohabitat
sudo docker compose up
It’s not building the schema and filling the object database in this current state, so you’ll need to modify line 46 in docker-compose.yml to true (NEOHABITAT_SHOULD_UPDATE_SCHEMA) and line 49 in run to true (SHOULD_UPDATE_SCHEMA=“${NEOHABITAT_SHOULD_UPDATE_SCHEMA:=true}”) before you run sudo docker compose up.
You’ll only want these set to true for the first time launching this NeoHabitat docker setup to populate the object database. Things will load much faster if you set those configuration options back to false after.
It’ll take a few minutes for all the services to come online after bringing the containers up, but when you see the following log output then you are ready to connect to the server:
neohabitat-neohabitat-1 | May 08, 2023 7:03:36 PM com.mongodb.diagnostics.logging.JULLogger log
neohabitat-neohabitat-1 | INFO: Opened connection [connectionId{localValue:2, serverValue:10}] to neohabitatmongo:27017
neohabitat-neohabitat-1 | - 2023/05/08 19:03:36.334 EVN cont : loading classDesc 'classes'
neohabitat-neohabitat-1 | - 2023/05/08 19:03:36.473 EVN cont : loading static object list 'statics'
neohabitat-neohabitat-1 | - 2023/05/08 19:03:36.515 EVN cont : loading static object 'teleports' as 'teleports'
Go into VICE and Settings > RS232 Settings > RS232 Settings. Set RS232 Device 1 to the IP of the NeoHabitat server and port 1986 (127.0.0.1:1986) for example.
Load Habitat-Boot.d64. Press return on the title screen. Type in the name you want for your avatar and press return. When on the main Habitat title screen, press Alt-N and any key and watch the server output.
The actual problem
The title screen should freeze and you’ll see this output in the logs:
neohabitat-neohabitat-1 | debug: Habitat connection from 172.18.0.4:1337
neohabitat-qlink-1 | 2023-05-08 19:06:19,191 [Thread-5] DEBUG org.jbrain.qlink.connection.QConnection - Sending Habitat Packet: 5A A1 4A B1 49 13 10 20 55 E0 00 03 32 30 30 00
neohabitat-qlink-1 | 2023-05-08 19:06:19,194 [Thread-6] INFO org.jbrain.qlink.connection.HabitatConnection - Initiating Habitat Reader thread
neohabitat-neohabitat-1 | events.js:165
neohabitat-neohabitat-1 | throw er; // Unhandled 'error' event
neohabitat-neohabitat-1 | ^
neohabitat-neohabitat-1 |
neohabitat-neohabitat-1 | Error: connect ECONNREFUSED 172.18.0.4:2018
neohabitat-neohabitat-1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)
neohabitat-neohabitat-1 | Emitted 'error' event at:
neohabitat-neohabitat-1 | at emitErrorNT (internal/streams/destroy.js:64:8)
neohabitat-neohabitat-1 | at process._tickCallback (internal/process/next_tick.js:178:19)
neohabitat-neohabitat-1 | Program node /neohabitat/bridge/Habitat2ElkoBridge.js -l 0.0.0.0:1337 -e neohabitat:2018 -m neohabitatmongo:27017/elko -c context-Downtown_5f -t debug exited with code 1
neohabitat-neohabitat-1 |
neohabitat-neohabitat-1 | Starting child process with 'node /neohabitat/bridge/Habitat2ElkoBridge.js -l 0.0.0.0:1337 -e neohabitat:2018 -m neohabitatmongo:27017/elko -c context-Downtown_5f -t debug'
neohabitat-neohabitat-1 | Missing/invalid defaults.elko configuration file. Proceeding with factory defaults.
neohabitat-neohabitat-1 | info: Habitat to Elko Bridge listening on 0.0.0.0:1337
According to the file docker-compose.yml, port 2018 is the NEOHABITAT_BRIDGE_ELKO_HOST.
For some reason, the connection is being refused. When this setup previously worked, we used ip addresses instead of giving a container a name and referring to that instead. I’m wondering if this is what has caused the issue here. We need this port to be accessible and responsive in order to have this Docker setup working again.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (9 by maintainers)
Nope. One of the changes I made was to set up a private network in the docker-compose.yml and attach each container to it. This exposes each container on that network to all the others, setting up hostnames as per the container name in the docker-compose.yml. All of a container’s ports are automatically accessible to all other containers in that network. The only time you need to set up a port mapping is it you have any external applications/clients that need to connect in. Hence only 1986 being left enabled, as that’s the port the c64 clients connect to. The other ports are still accessible from any code running within the containers, as long as you use the hostname and not localhost (as that counts as an external address.) Doing this isolates the services, stopping clashes with anything else running in the server (I already had a mariaDB running, for instance) and/or lets you run multiple instances of neohabitat - just change that external port number for each one.
I added some commits to #402 that correct the node dependency issues. There was a volume attached to the neohabitat container that would wipe out all the containers contents with local file system contents causing a disparity between what was installed locally and in the container:
https://github.com/frandallfarmer/neohabitat/blob/master/docker-compose.yml#LL37C1-L38C22
I imagine someone left this in for local development purposes but is unnecessary and detrimental to a deterministic build.
I also separated the
package.jsonhierarchy forbridgeandpushserverthis seems to resolve the missing node dependencies Stu reported above.Ok here is confirmation that the
pushserver/node_modulesdependencies are there at build time but missing at run time :So something is deleting
pushserver/node_modulesat runtime :\ ??Very strange I was seeing those pushserver dependency issues and that’s what led me to moving the
npm installinto theDockerfile. I have confirmed that if I start a new container from theneohabitatimage the dependencies are installed in/pushserver/node_moduleshowever if I connect to the already runningneohabibtatcontainer the/pushserver/node_modulesis missing looking further.Ok I’m fairly confident that this line should not be commented out: https://github.com/frandallfarmer/neohabitat/blob/master/docker-compose.yml#L59
The following output is copied from Stu’s post above:
The ports on the philcollins/neohabitat container are listed but not forwarded. If we uncomment the ports in
docker-compose.ymlthey show up as forwardedcompare the output and notice the
->indicated ports are now forwarded into the containers.I haven’t been able to test this yet i’m not setup with the VICE emulator maybe @StuBlad can try it quick.