refactor(ferretdb): keep the install agnostic, drop LibreChat-specific wiring
The script installs and exposes the database only; it now prints a generic MongoDB connection string (mongodb://user:pass@ip:27017/) instead of a LibreChat MONGO_URI with a hardcoded /LibreChat database. README 'Wiring LibreChat' section replaced with a generic 'Connecting a client' section. Application wiring is left to that app's own config or a separate script.
This commit is contained in:
@@ -3,8 +3,10 @@
|
|||||||
Automated installation and update script for [FerretDB](https://www.ferretdb.io) — a truly
|
Automated installation and update script for [FerretDB](https://www.ferretdb.io) — a truly
|
||||||
open-source, MongoDB-compatible database — running inside a **Debian LXC** on Proxmox.
|
open-source, MongoDB-compatible database — running inside a **Debian LXC** on Proxmox.
|
||||||
|
|
||||||
Built to give [LibreChat](https://www.librechat.ai) a drop-in MongoDB replacement without
|
A drop-in MongoDB replacement for any app that speaks the MongoDB wire protocol (e.g.
|
||||||
running MongoDB itself (whose recent releases break on current kernels).
|
[LibreChat](https://www.librechat.ai)) without running MongoDB itself. The script installs
|
||||||
|
and exposes the database only; wiring it into an application is left to that app's own
|
||||||
|
configuration (a separate script, or manually).
|
||||||
|
|
||||||
### Why Debian and not Alpine?
|
### Why Debian and not Alpine?
|
||||||
|
|
||||||
@@ -72,7 +74,7 @@ Every parameter is exposed as an environment variable:
|
|||||||
| `DOCUMENTDB_TAG` | `latest` | DocumentDB release tag (couples documentdb + FerretDB versions); pin e.g. `v0.107.0-ferretdb-2.7.0` |
|
| `DOCUMENTDB_TAG` | `latest` | DocumentDB release tag (couples documentdb + FerretDB versions); pin e.g. `v0.107.0-ferretdb-2.7.0` |
|
||||||
| `DOCUMENTDB_DISTRO` | `deb12` | Distro target in the documentdb deb filename. Escape hatch for a future `deb13` (set with `TEMPLATE`) |
|
| `DOCUMENTDB_DISTRO` | `deb12` | Distro target in the documentdb deb filename. Escape hatch for a future `deb13` (set with `TEMPLATE`) |
|
||||||
| `FERRETDB_LISTEN_ADDR` | `0.0.0.0:27017` | TCP listener. Exposed on all interfaces — it is a database other hosts must reach. |
|
| `FERRETDB_LISTEN_ADDR` | `0.0.0.0:27017` | TCP listener. Exposed on all interfaces — it is a database other hosts must reach. |
|
||||||
| `FERRETDB_USER` | `ferretdb` | App user — both the PostgreSQL role and the MongoDB user LibreChat authenticates as |
|
| `FERRETDB_USER` | `ferretdb` | App user — both the PostgreSQL role and the MongoDB user clients authenticate as |
|
||||||
| `FERRETDB_PASSWORD` | auto-generated | Auto-generated (`openssl rand -hex 24`) when unset; printed in the final summary |
|
| `FERRETDB_PASSWORD` | auto-generated | Auto-generated (`openssl rand -hex 24`) when unset; printed in the final summary |
|
||||||
| `TS_AUTHKEY` | _(unset)_ | Pre-auth key (generate at <https://login.tailscale.com/admin/settings/keys>). If unset, finish `tailscale up` manually inside the LXC. |
|
| `TS_AUTHKEY` | _(unset)_ | Pre-auth key (generate at <https://login.tailscale.com/admin/settings/keys>). If unset, finish `tailscale up` manually inside the LXC. |
|
||||||
|
|
||||||
@@ -81,35 +83,23 @@ CTID=220 FERRETDB_HOSTNAME=mongo RAM=4096 DISK=32 \
|
|||||||
bash -c "$(curl -fsSL https://gitea.arnodo.fr/Damien/infra-scripts/raw/branch/main/ferretdb/install.sh)"
|
bash -c "$(curl -fsSL https://gitea.arnodo.fr/Damien/infra-scripts/raw/branch/main/ferretdb/install.sh)"
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Wiring LibreChat
|
#### Connecting a client
|
||||||
|
|
||||||
LibreChat talks to FerretDB exactly as it would to MongoDB. Point its `MONGO_URI` at the
|
Any MongoDB driver or tool connects with a standard connection string (the script prints the
|
||||||
container and **remove the bundled `mongodb` service** so it doesn't start:
|
exact one, with the generated password, at the end of the install):
|
||||||
|
|
||||||
```env
|
```
|
||||||
# LibreChat .env
|
mongodb://ferretdb:<password>@<lxc-ip-or-tailnet-fqdn>:27017/
|
||||||
MONGO_URI=mongodb://ferretdb:<password>@<lxc-ip-or-tailnet-fqdn>:27017/LibreChat
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you run LibreChat with the upstream `docker-compose.yml`, drop the dependency on the local
|
Append a database name to target one (e.g. `…:27017/myapp`); it is created on first write.
|
||||||
Mongo service in `docker-compose.override.yml`:
|
Wiring this into a specific application (setting its Mongo connection string, disabling any
|
||||||
|
bundled MongoDB it ships, etc.) is intentionally out of scope — do it from that app's own
|
||||||
```yaml
|
config or a dedicated script.
|
||||||
services:
|
|
||||||
api:
|
|
||||||
environment:
|
|
||||||
- MONGO_URI=mongodb://ferretdb:<password>@<lxc-ip>:27017/LibreChat
|
|
||||||
# disable the bundled mongodb service (don't start it)
|
|
||||||
mongodb:
|
|
||||||
profiles: [donotstart]
|
|
||||||
```
|
|
||||||
|
|
||||||
LibreChat creates the `LibreChat` database on first connection and stores all conversations
|
|
||||||
and settings there.
|
|
||||||
|
|
||||||
#### Tailscale
|
#### Tailscale
|
||||||
|
|
||||||
The LXC joins the tailnet (`tailscale up --ssh`) so LibreChat on another node can reach the
|
The LXC joins the tailnet (`tailscale up --ssh`) so a client on another node can reach the
|
||||||
database over the tailnet. Unlike the `openbao` script there is **no `tailscale serve`** — the
|
database over the tailnet. Unlike the `openbao` script there is **no `tailscale serve`** — the
|
||||||
MongoDB wire protocol is raw TCP, not HTTP, so the listener is exposed directly on
|
MongoDB wire protocol is raw TCP, not HTTP, so the listener is exposed directly on
|
||||||
`0.0.0.0:27017` (LAN + tailnet) by design.
|
`0.0.0.0:27017` (LAN + tailnet) by design.
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ DOCUMENTDB_TAG="${DOCUMENTDB_TAG:-latest}"
|
|||||||
DOCUMENTDB_DISTRO="${DOCUMENTDB_DISTRO:-deb12}"
|
DOCUMENTDB_DISTRO="${DOCUMENTDB_DISTRO:-deb12}"
|
||||||
DOCUMENTDB_RELEASES_URL="${DOCUMENTDB_RELEASES_URL:-https://api.github.com/repos/FerretDB/documentdb/releases}"
|
DOCUMENTDB_RELEASES_URL="${DOCUMENTDB_RELEASES_URL:-https://api.github.com/repos/FerretDB/documentdb/releases}"
|
||||||
# As a database we deliberately expose the listener on all interfaces so other
|
# As a database we deliberately expose the listener on all interfaces so other
|
||||||
# hosts (LibreChat) can reach it over the LAN / tailnet. PostgreSQL stays local.
|
# hosts can reach it over the LAN / tailnet. PostgreSQL stays local.
|
||||||
FERRETDB_LISTEN_ADDR="${FERRETDB_LISTEN_ADDR:-0.0.0.0:27017}"
|
FERRETDB_LISTEN_ADDR="${FERRETDB_LISTEN_ADDR:-0.0.0.0:27017}"
|
||||||
# Application credentials. The same user/password is both the PostgreSQL role
|
# Application credentials. The same user/password is both the PostgreSQL role
|
||||||
# FerretDB connects with AND the MongoDB user LibreChat authenticates as.
|
# FerretDB connects with AND the MongoDB user clients authenticate as.
|
||||||
FERRETDB_USER="${FERRETDB_USER:-ferretdb}"
|
FERRETDB_USER="${FERRETDB_USER:-ferretdb}"
|
||||||
FERRETDB_PASSWORD="${FERRETDB_PASSWORD:-}" # auto-generated when empty
|
FERRETDB_PASSWORD="${FERRETDB_PASSWORD:-}" # auto-generated when empty
|
||||||
# Optional: pre-authorise the LXC's Tailscale non-interactively.
|
# Optional: pre-authorise the LXC's Tailscale non-interactively.
|
||||||
@@ -389,8 +389,8 @@ EOF
|
|||||||
echo " IP : ${ip:-pending}"
|
echo " IP : ${ip:-pending}"
|
||||||
echo " FerretDB : ${FERRETDB_LISTEN_ADDR}"
|
echo " FerretDB : ${FERRETDB_LISTEN_ADDR}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "LibreChat connection string (set as MONGO_URI in LibreChat's .env):"
|
echo "MongoDB connection string (point your client/app at it):"
|
||||||
echo " mongodb://${FERRETDB_USER}:${FERRETDB_PASSWORD}@${ip:-<ip>}:27017/LibreChat"
|
echo " mongodb://${FERRETDB_USER}:${FERRETDB_PASSWORD}@${ip:-<ip>}:27017/"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Store this password somewhere safe — it is not persisted on the host:"
|
echo "Store this password somewhere safe — it is not persisted on the host:"
|
||||||
echo " user : ${FERRETDB_USER}"
|
echo " user : ${FERRETDB_USER}"
|
||||||
@@ -589,9 +589,9 @@ echo "Status:"
|
|||||||
echo " • FerretDB : ${FERRET_STATE} (listening on ${FERRETDB_LISTEN_ADDR})"
|
echo " • FerretDB : ${FERRET_STATE} (listening on ${FERRETDB_LISTEN_ADDR})"
|
||||||
echo " • PostgreSQL : ${PG_STATE} (127.0.0.1:5432)"
|
echo " • PostgreSQL : ${PG_STATE} (127.0.0.1:5432)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "LibreChat MONGO_URI:"
|
echo "Connection string (MongoDB URI):"
|
||||||
echo " mongodb://${FERRETDB_USER}:<password>@${LAN_IP:-<ip>}:27017/LibreChat"
|
echo " mongodb://${FERRETDB_USER}:<password>@${LAN_IP:-<ip>}:27017/"
|
||||||
echo " (tailnet) mongodb://${FERRETDB_USER}:<password>@${TS_FQDN}:27017/LibreChat"
|
echo " (tailnet) mongodb://${FERRETDB_USER}:<password>@${TS_FQDN}:27017/"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Useful commands:"
|
echo "Useful commands:"
|
||||||
echo " systemctl status ferretdb postgresql"
|
echo " systemctl status ferretdb postgresql"
|
||||||
@@ -613,8 +613,8 @@ MOTD
|
|||||||
log_info "FerretDB installation complete!"
|
log_info "FerretDB installation complete!"
|
||||||
log_info "========================================="
|
log_info "========================================="
|
||||||
echo ""
|
echo ""
|
||||||
echo "Set this as MONGO_URI in LibreChat's .env:"
|
echo "MongoDB connection string (point your client/app at it):"
|
||||||
echo " mongodb://${FERRETDB_USER}:${FERRETDB_PASSWORD}@${ip:-<ip>}:27017/LibreChat"
|
echo " mongodb://${FERRETDB_USER}:${FERRETDB_PASSWORD}@${ip:-<ip>}:27017/"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Credentials (store safely — not persisted on the Proxmox host):"
|
echo "Credentials (store safely — not persisted on the Proxmox host):"
|
||||||
echo " user : ${FERRETDB_USER}"
|
echo " user : ${FERRETDB_USER}"
|
||||||
|
|||||||
Reference in New Issue
Block a user