database

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package database defines supported database engines and their container configurations for one-click local provisioning via devx db spawn.

Index

Constants

This section is empty.

Variables

View Source
var Registry = map[string]Engine{
	"postgres": {
		Name:         "PostgreSQL",
		Image:        "docker.io/library/postgres:16-alpine",
		DefaultPort:  5432,
		InternalPort: 5432,
		VolumePath:   "/var/lib/postgresql/data",
		Env: map[string]string{
			"POSTGRES_USER":     "devx",
			"POSTGRES_PASSWORD": "devx",
			"POSTGRES_DB":       "devx",
		},
		ReadyLog:      "database system is ready to accept connections",
		ConnStringFmt: "postgresql://%s:%s@localhost:%d/%s",
	},
	"redis": {
		Name:          "Redis",
		Image:         "docker.io/library/redis:7-alpine",
		DefaultPort:   6379,
		InternalPort:  6379,
		VolumePath:    "/data",
		Env:           map[string]string{},
		ReadyLog:      "Ready to accept connections",
		ConnStringFmt: "redis://localhost:%d",
	},
	"mysql": {
		Name:         "MySQL",
		Image:        "docker.io/library/mysql:8",
		DefaultPort:  3306,
		InternalPort: 3306,
		VolumePath:   "/var/lib/mysql",
		Env: map[string]string{
			"MYSQL_ROOT_PASSWORD": "devx",
			"MYSQL_DATABASE":      "devx",
			"MYSQL_USER":          "devx",
			"MYSQL_PASSWORD":      "devx",
		},
		ReadyLog:      "ready for connections",
		ConnStringFmt: "mysql://%s:%s@localhost:%d/%s",
	},
	"mongo": {
		Name:         "MongoDB",
		Image:        "docker.io/library/mongo:7",
		DefaultPort:  27017,
		InternalPort: 27017,
		VolumePath:   "/data/db",
		Env: map[string]string{
			"MONGO_INITDB_ROOT_USERNAME": "devx",
			"MONGO_INITDB_ROOT_PASSWORD": "devx",
		},
		ReadyLog:      "Waiting for connections",
		ConnStringFmt: "mongodb://%s:%s@localhost:%d",
	},
}

Registry of all supported database engines.

Functions

func SupportedEngines

func SupportedEngines() []string

SupportedEngines returns a sorted list of engine names.

Types

type Engine

type Engine struct {
	Name          string            // Human-readable name
	Image         string            // Container image
	DefaultPort   int               // Default port on the host
	InternalPort  int               // Port inside the container
	VolumePath    string            // Data directory inside the container
	Env           map[string]string // Default environment variables
	ReadyLog      string            // Log line that indicates the DB is ready
	ConnStringFmt string            // printf format for the connection string: host, port, user, pass, dbname
}

Engine holds the container configuration for a database engine.

func (Engine) ConnString

func (e Engine) ConnString(port int) string

ConnString returns the formatted connection string for a given engine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL