From 1dd09147ed6cd4ca59ce1ae8ab4467ea10eed7ba Mon Sep 17 00:00:00 2001 From: Marcus Lagergren <1062473+lagergren@users.noreply.github.com> Date: Sat, 7 Nov 2026 15:40:10 +0100 Subject: [PATCH] Print the link to play once the bitmap server is up, and run the game with one docker command Once the server accepts connections it prints the game's name and version and, on a line of its own so terminals make it clickable, the link to open: the login page, or the game itself in a --user session. The address is the bind address, with a wildcard read as localhost, unless RYLWEEN_PUBLIC_URL or --public-url names another; the start log event records it too. With that, a machine with only Docker or Podman and internet access plays with one command, which the README now leads with: docker run --rm -it --pull always --name rylween -p 127.0.0.1:8081:8081 -v rylween-data:/data -e RYLWEEN_AUTH_SECURE_COOKIES=false ghcr.io/lagergren/rylween It pulls the latest release, starts it, and prints http://localhost:8081/login. The README also covers getting Docker or Podman with Homebrew, where `brew install docker` alone lacks the engine, and the release notes give the same command for the release's own image. --- .github/workflows/release.yml | 11 ++-- README.md | 26 +++++++++ .../bitmapweb/RylweenBitmapWebRuntimeMain.kt | 54 ++++++++++++++++++- 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 559c1468..6a03dcc6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -237,13 +237,14 @@ jobs: cat > "$RUNNER_TEMP/notes.md" < { + index += 1 + publicUrl = requiredValue(args, index, arg) + } "--help", "-h" -> { printUsage() exitProcess(0) @@ -283,9 +293,27 @@ private data class BitmapWebConfig( debugSecrets, mapTiles, tileSize, + publicUrl?.let { url -> url.trimEnd('/') + "/" } ?: defaultPublicUrl(host, port), ) } + /** + * The address to advertise when none is given: the bind address, where a wildcard means this machine. In a + * container that is localhost with the same port, as the documented `docker run -p 127.0.0.1:8081:8081` maps it. + */ + private fun defaultPublicUrl( + host: String, + port: Int, + ): String { + val reachableHost = + when { + host == "0.0.0.0" || host == "::" -> "localhost" + ':' in host -> "[$host]" + else -> host + } + return "http://$reachableHost:$port/" + } + private fun envOrDefault( key: String, defaultValue: String, @@ -318,7 +346,7 @@ private data class BitmapWebConfig( private fun printUsage() { println( """ - Usage: rylween-bitmap-web [--host HOST] [--port PORT] [--data DIR] [--state SLUG] [--bundle FILE] [--user ID] [--load FILE] [--save FILE] [--account NAME --password PASSWORD [--email EMAIL]] [--secure-cookies] [--title|--no-title] [--debug-secrets] [--map-tiles N] [--tile-size PX] + Usage: rylween-bitmap-web [--host HOST] [--port PORT] [--data DIR] [--state SLUG] [--bundle FILE] [--user ID] [--load FILE] [--save FILE] [--account NAME --password PASSWORD [--email EMAIL]] [--secure-cookies] [--title|--no-title] [--debug-secrets] [--map-tiles N] [--tile-size PX] [--public-url URL] The bitmap runtime uses the embedded :game bundle by default. --bundle can point at build/compiled/rylween-bundle.json to exercise an emitted artifact instead. @@ -326,6 +354,8 @@ private data class BitmapWebConfig( --account/--password ensures an auth account exists before the server starts. --secure-cookies adds the Secure cookie attribute for HTTPS deployments. --debug-secrets enables hidden manual-test wilderness commands, including M for the annotated full map. + --public-url (RYLWEEN_PUBLIC_URL) is the address players open, which the server prints once it is up. + It defaults to the bind address, with a wildcard read as localhost. Map defaults: ${DEFAULT_BITMAP_VIEWPORT_TILES}x${DEFAULT_BITMAP_VIEWPORT_TILES} tiles at ${DEFAULT_BITMAP_TILE_SIZE}px. """.trimIndent(), ) @@ -399,8 +429,9 @@ private class BitmapWebServer( "devUser=${config.userId.orEmpty()} load=${config.loadFile?.path.orEmpty()} " + "save=${config.worldSaveFile.path} title=${config.showTitleMenu} " + "debugSecrets=${config.debugSecrets} mapTiles=${config.mapTiles} tileSize=${config.tileSize} " + - "bundle=${game.source}", + "bundle=${game.source} url=${config.entryUrl}", ) + announceEntry(game.bundle.content.let { content -> content.strings.value(content.universe.nameString) }, config.entryUrl) while (!serverSocket.isClosed) { val socket = serverSocket.accept() executor.execute { handleClient(socket) } @@ -1108,6 +1139,25 @@ private fun streamServerLog(line: String) { println("[rylween-bitmap] $line") } +/** + * Tells whoever started the server where to play, once it accepts connections. The link has a line of its own, so + * terminals make all of it, and nothing more, clickable. + */ +private fun announceEntry( + gameName: String, + url: String, +) { + println( + """ + | + |$gameName $rylweenVersion is up. To play, open: + | + | $url + | + """.trimMargin(), + ) +} + private fun serverLogValue(value: String): String = "\"" + value.replace("\\", "\\\\").replace("\"", "\\\"") + "\"" private fun String?.toBitmapFacingOrDefault(): BitmapWildernessFacing =