Files
Juan DenisandClaude Opus 5 3070353631 feat(databases): install any engine, because an engine is just a template
You could not install a database from ServerKit. The tree's four roots were
literals, only MySQL and PostgreSQL reported real state, and no install path
existed anywhere in the backend.

Rather than add one, this makes a database engine an ordinary app template that
declares a top-level `engine:` block — family, wire protocol, admin user, which
variable holds the password, what it calls a "table". Presence of that block is
the only thing that lists a template in the Databases catalog, and installing it
is the template pipeline that already existed: same deployment job, same
streaming console.

The consequence is the point. Adding CockroachDB is adding a YAML file. So is
adding something we have never heard of — author it locally or sync a template
repo — and the install form still works, because it is generated from the
template's own `variables[]` rather than hand-written per engine. There is no
engine model, no engine table, no engine install mechanism to keep in step.
`test_dropping_a_new_engine_yaml_lists_it` is the design; if it ever needs code
to pass, this went wrong.

Twelve engines ship: postgresql, mysql, mariadb, mongodb, redis, valkey,
cockroachdb, clickhouse, influxdb, neo4j, meilisearch, couchdb. Each pins its
image, binds to loopback, names a data volume, and was checked against the
upstream image's actual environment contract — a wrong variable name is a
container that boots with authentication silently disabled.

Two safety notes worth reading. Engines bind 127.0.0.1 unless explicitly
exposed, and the flag is applied after caller variables so a handcrafted payload
cannot quietly publish one. And CockroachDB single-node runs `--insecure`
because password auth needs a certificate-backed cluster: for engines with no
credentials at all the loopback bind is the only control, so public exposure is
refused outright rather than warned about. A test pins the passwordless list to
exactly cockroachdb, so a future template that drops its password variable
fails loudly instead of opening a hole.

Also surfaced at last: `ManagedDatabase.owner_application_id` has been accepted
by the create endpoints for ages with no UI to set it. Creating a database now
offers "Attach to application".

Deferred deliberately: new-table builder, SQL dump import, engine extensions
(pgvector, TimescaleDB) — each a data-mutation surface deserving its own round.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 20:09:05 -04:00

82 lines
1.9 KiB
YAML

id: mongodb
name: MongoDB
version: "7.0"
description: Document store with flexible schemas, aggregation pipelines and change streams
icon: https://serverkit.ai/imgs/template-icons/mongodb.svg
categories:
- database
- nosql
website: https://www.mongodb.com
documentation: https://www.mongodb.com/docs/manual/
engine:
family: Document
protocol: mongodb
default_port: 27017
admin_user: root
admin_password_var: DB_PASSWORD
database_var: DB_NAME
port_var: PORT
bind_var: BIND_ADDRESS
unit: collections
client: mongosh
data_path: /data/db
version_var: IMAGE_TAG
versions:
- "7.0"
- "6.0"
variables:
- name: IMAGE_TAG
type: string
default: "7.0"
hidden: true
description: Image tag; constrained to engine.versions by the installer
- name: PORT
type: port
default: "27017"
hidden: false
description: Host port to publish MongoDB on
- name: BIND_ADDRESS
type: string
default: 127.0.0.1
hidden: true
description: Address the port binds to. 127.0.0.1 keeps the engine private.
- name: DB_PASSWORD
type: password
length: 28
description: Password for the MongoDB root user
- name: DB_NAME
type: string
default: app
description: Initial database to create
compose:
services:
app:
image: mongo:${IMAGE_TAG}
container_name: ${APP_NAME}
restart: unless-stopped
ports:
- "${BIND_ADDRESS}:${PORT}:27017"
environment:
# BOTH of these must be present. With only one set, the entrypoint
# starts mongod with authentication DISABLED.
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: "${DB_PASSWORD}"
MONGO_INITDB_DATABASE: "${DB_NAME}"
volumes:
- mongodb-data:/data/db
volumes:
mongodb-data:
ports:
- port: "${PORT}"
protocol: mongodb
description: MongoDB wire protocol
requirements:
memory: 1GB
storage: 10GB