Skip to content

build: (all branches) Add Docker build instructions#104

Open
richardcoucoules wants to merge 3 commits into
LostCityRS:274from
richardcoucoules:docker
Open

build: (all branches) Add Docker build instructions#104
richardcoucoules wants to merge 3 commits into
LostCityRS:274from
richardcoucoules:docker

Conversation

@richardcoucoules

@richardcoucoules richardcoucoules commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Adds a Dockerfile which constructs an image from the contents of the checked out branch. The intention is to make cross-platform self-hosting and dependency management much easier and sandboxes the runtime such that it's not on a host's baremetal with access to their filesystem/resources. This differs from the Server repo in that it is intended to be a non-interactive, single-command deployment.

The image is constructed by transpiling the TS code to JS with typescript tsc and running the output directly with node (as opposed to using tsx, which the existing dev scripts do), which should cut down on dependency size and processor load while running. To this end, two new npm scripts were added: compile, which transpiles the TS to JS files and start:compiled which starts a node server with an entrypoint at the transpiled app.js file.

I encountered and addressed two transpilation issues in the existing repo while doing this:

  • src/server/login/index.d.ts is defined as a typescript declaration file but contains some logic (i.e., the isPlayerLoginResponse and isPlayerLogoutResponse functions). Declaration files are ignored by the transpiler, leading to module not found errors, so this file was changed to a raw TS file to more accurately convey the contents of the file.
  • new URL('*.ts') invocations don't survive the transpilation step, as the *.ts target is not changed from the TS -> JS representation of the file and the transpiled output doesn't have access to the original TS files (nor could it parse them if it did). The suggestion in this PR is to change all of those to .js targets, which should work for both the JIT transpilation from tsx and the pre-transpilation from tsc.
  • A production condition was added to package.json imports directive specifying that aliased import paths should resolve to ./out/*. This fixes bugs in aliased imports resolution which expect files relative to the root directory.

These seem innocuous enough to include in the same PR, but I'm somewhat wary of the second change and would appreciate a sanity check from anyone who's well versed in what these Worker/URLs are doing and what appropriate testing would be in this domain.

Testing

This image is currently being served at https://rs.coucoul.es/rs2.cgi with localhost-based login, friend, and logger servers. A test user is created with credentials lostcitytest !test123! for demonstration.

In addition, ran basic e2e regression tests

  • Confirmed npm start still works locally, bringing up the server and a functioning webclient
  • Confirmed the new transpiled server works identically to the existing server kicked off by npm start
  • Built the docker image and confirmed it works identically to the servers in the previous steps

The container can be built and tested by doing

docker build -t lost-city-rs/engine .
docker run -it -v <local reference to content directory>:/opt/server/content -p 8888:80 --rm lost-city-rs/engine

where <local reference to content directory> is the file path to the local copy of the Content repo; based on the description of that repo, the contents are Jagex IP and so should probably not be packaged in this container.

More customization can be done by mounting a world.json file to the container (add -v <world.json location>:/opt/server/engine/data/config/world.json to the docker run command above). This was tested briefly to confirm that the friend, logger, and login servers successfully spun up (see attached logs below), but I did not go through a full registration/sign in workflow.

~/code/lost-city/test ❯ docker run -it -v ./lost-city/content:/opt/server/content -v ./world.json:/opt/server/engine/data/config/world.json -p 8888:80 --rm lostcity-engine
6/10/2026 8:12:55 PM	 INFO	 Starting world
6/10/2026 8:13:00 PM	 DEBUG	 Loading game map
6/10/2026 8:13:02 PM	 DEBUG	 7321/16383 static NPCs added
6/10/2026 8:13:02 PM	 INFO	 World ready: Visit http://localhost/rs2.cgi
6/10/2026 8:13:00 PM	 INFO	 Login server listening on port 43500
6/10/2026 8:12:58 PM	 INFO	 Friend server listening on port 45099
6/10/2026 8:12:58 PM	 INFO	 Logger server listening on port 43501

@richardcoucoules richardcoucoules changed the title Add Docker build instructions build:Add Docker build instructions Jun 10, 2026
@richardcoucoules richardcoucoules changed the title build:Add Docker build instructions build: Add Docker build instructions Jun 10, 2026
@richardcoucoules richardcoucoules changed the title build: Add Docker build instructions build: (all branches) Add Docker build instructions Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant