diff --git a/dbuild/templates/README.j2 b/dbuild/templates/README.j2 index 7eb675c..1cd8be9 100644 --- a/dbuild/templates/README.j2 +++ b/dbuild/templates/README.j2 @@ -571,7 +571,9 @@ Save as `bastille-compose.yml`, then run `bastille up`. {%- if ports and cit_mode in ("health", "screenshot") %} -Access at: `http://localhost:{{ ports[0].port if render_mode != "mkdocs" else port_var }}` +{#- Not localhost: a published port is a pf rdr, and pf never redirects the + host's own connections to it. #} +Open `http://:{{ ports[0].port if render_mode != "mkdocs" else port_var }}` from another machine (the server's own browser can't use a published port). {%- endif %} {%- endif %} {%- endblock %} diff --git a/tests/test_docs.py b/tests/test_docs.py index 1b0d725..8e4e86c 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -1114,3 +1114,31 @@ def test_a_combination_without_env_has_no_env_step(self): podman = outputs["README.md"].split("### Podman Compose", 1)[1].split("### AppJail", 1)[0] self.assertNotIn("Save as `.env`", podman, "no .env to fill in") self.assertIn("Save as `compose.yaml`:", podman) + + +class TestAccessLine(unittest.TestCase): + def test_access_is_from_another_machine_not_localhost(self): + with tempfile.TemporaryDirectory() as d: + repo = Path(d) + (repo / ".daemonless").mkdir() + (repo / ".daemonless" / "config.yaml").write_text("cit:\n mode: health\n") + (repo / "compose.yaml").write_text( + "x-daemonless:\n" + " title: \"Web\"\n" + " description: \"A web app.\"\n" + " category: \"Utilities\"\n" + " upstream_url: \"https://example.com\"\n" + "services:\n" + " web:\n" + " image: ghcr.io/daemonless/web:latest\n" + " ports:\n" + " - \"8080:8080\"\n" + ) + (repo / "Containerfile.j2").write_text(CONTAINERFILE_J2) + with _chdir(repo): + cfg = dbuild_config.load(repo) + outputs, errors = docs.render_generated(cfg, argparse.Namespace(community=None), repo) + self.assertEqual(errors, []) + readme = outputs["README.md"] + self.assertIn("Open `http://:8080` from another machine", readme) + self.assertNotIn("http://localhost:", readme)