Use Starlette, uvicorn and websockets; rename Docker files to container ones

Serve neo4j-browser with Starlette and uvicorn (the optional browser extra)
instead of a hand-written HTTP server, and handle Bolt over WebSocket with the
websockets library's Sans-I/O protocol. Rename Dockerfile, .dockerignore and
docker/ to Containerfile, .containerignore and container/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bart BroereandClaude Opus 5.5 committed 2026-10-21 11:27:25 +02:00
1 parent 3e8e498b56
commit f0fb9ddc74
18 files changed
+189 -162

No files matched your search

+19 -8
View File
@@ -32,9 +32,17 @@ The `binary` extra pulls in psycopg's prebuilt wheels; leave it out to use a psy
built against your system's libpq. `python -m peo` works the same as `peo`.
Neo4j clients can now connect to `neo4j://localhost:7687` with a PostgreSQL user name
and password. peo does not include neo4j-browser itself: build it and point
`PEO_BROWSER_DIR` at its `dist` directory to serve it on <http://localhost:7474/>, or
use the container image.
and password.
peo does not include neo4j-browser itself. To serve it, install the `browser` extra
([Starlette](https://www.starlette.io/) and [uvicorn](https://www.uvicorn.org/)),
build neo4j-browser and point `PEO_BROWSER_DIR` at its `dist` directory; it is then
served on <http://localhost:7474/>. The container image does all of this for you.
```sh
pip install 'peo[binary,browser]'
PEO_PG_HOST=localhost PEO_PG_DATABASE=postgres PEO_BROWSER_DIR=/path/to/neo4j-browser/dist peo
```
## Configuration
@@ -48,7 +56,7 @@ peo is configured through environment variables:
| `PEO_DEFAULT_GRAPH` | `neo4j` | Graph used when a client does not pick a database. |
| `PEO_BOLT_PORT` | `7687` | Port the Bolt server listens on (TCP and WebSocket). |
| `PEO_HTTP_PORT` | `7474` | Port neo4j-browser is served on, when `PEO_BROWSER_DIR` is set. |
| `PEO_BROWSER_DIR` | (unset) | neo4j-browser `dist` directory to serve. |
| `PEO_BROWSER_DIR` | (unset) | neo4j-browser `dist` directory to serve; needs the `browser` extra. |
| `PEO_ADVERTISED_BOLT_PORT` | `$PEO_BOLT_PORT` | Bolt port advertised to the browser; set it when clients reach the Bolt port on another port. |
| `PEO_ADVERTISED_HOST` | `localhost` | Host reported in `SHOW DATABASES` and to clients that do not send a routing address. |
| `PEO_LOG_LEVEL` | `INFO` | `DEBUG` logs every generated SQL statement. |
@@ -151,7 +159,9 @@ pgAdmin comes with the bundled PostgreSQL server already registered as "peo";
it asks for the PostgreSQL password the first time you open it. AGE stores each
graph as a schema of the same name, with one table per label.
`docker` works as a drop-in replacement for `podman` in the commands above.
Any OCI-compatible build tool works. With Docker, pass the file name explicitly:
`docker build -f Containerfile -t peo .`; `docker run` takes the same options as
`podman run`.
Besides peo's own variables above, the image uses these:
@@ -186,11 +196,12 @@ This is a first version. Things that do not work (yet):
## Development
peo's only dependency is `psycopg` 3. To work on it, install it in editable mode;
`python -m build` (or `uv build`) builds an sdist and wheel:
peo depends on `psycopg` 3 and `websockets`, plus Starlette and uvicorn for the
`browser` extra. To work on it, install it in editable mode; `python -m build` (or
`uv build`) builds an sdist and wheel:
```sh
pip install -e '.[binary]'
pip install -e '.[binary,browser]'
```
[`tests/smoke_test.py`](tests/smoke_test.py) runs end-to-end checks through the official