Files
ServerKit/backend/templates/mysql.yaml
T
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

83 lines
2.0 KiB
YAML

id: mysql
name: MySQL
version: "8.4"
description: The most widely deployed open-source relational database, with InnoDB storage and mature replication
icon: https://serverkit.ai/imgs/template-icons/mysql.svg
categories:
- database
- sql
website: https://www.mysql.com
documentation: https://dev.mysql.com/doc/
engine:
family: Relational
protocol: mysql
default_port: 3308
admin_user: root
admin_password_var: DB_PASSWORD
database_var: DB_NAME
port_var: PORT
bind_var: BIND_ADDRESS
unit: tables
client: mysql
data_path: /var/lib/mysql
version_var: IMAGE_TAG
versions:
- "8.4"
- "8.0"
variables:
- name: IMAGE_TAG
type: string
default: "8.4"
hidden: true
description: Image tag; constrained to engine.versions by the installer
- name: PORT
type: port
# 3306 is the host MySQL, 3307 the MariaDB template -- start above both.
default: "3308"
hidden: false
description: Host port to publish MySQL 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 MySQL root user
- name: DB_NAME
type: string
default: app
description: Initial database to create
compose:
services:
app:
image: mysql:${IMAGE_TAG}
container_name: ${APP_NAME}
restart: unless-stopped
ports:
- "${BIND_ADDRESS}:${PORT}:3306"
environment:
# MYSQL_ROOT_PASSWORD is required; the alternatives
# (MYSQL_ALLOW_EMPTY_PASSWORD / MYSQL_RANDOM_ROOT_PASSWORD) are exactly
# what we do NOT want for a managed engine.
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_DATABASE: "${DB_NAME}"
volumes:
- mysql-data:/var/lib/mysql
volumes:
mysql-data:
ports:
- port: "${PORT}"
protocol: mysql
description: MySQL wire protocol
requirements:
memory: 512MB
storage: 5GB