From 3543a9c809e86c0b32268f5d30f6fbe11bf064ab Mon Sep 17 00:00:00 2001 From: Cyril Beeckman Date: Mon, 2 May 2022 16:25:24 +0200 Subject: [PATCH] Added MariaDB database --- src/lib/components/DatabaseLinks.svelte | 3 + src/lib/components/common.ts | 6 + .../components/svg/databases/MariaDB.svelte | 10 ++ src/lib/database/common.ts | 127 +++++++++++------- src/lib/database/databases.ts | 4 + .../[id]/_Databases/_Databases.svelte | 3 + .../databases/[id]/_Databases/_MariaDB.svelte | 79 +++++++++++ .../databases/[id]/configuration/type.svelte | 3 + src/routes/databases/index.svelte | 5 + 9 files changed, 190 insertions(+), 50 deletions(-) create mode 100644 src/lib/components/svg/databases/MariaDB.svelte create mode 100644 src/routes/databases/[id]/_Databases/_MariaDB.svelte diff --git a/src/lib/components/DatabaseLinks.svelte b/src/lib/components/DatabaseLinks.svelte index 9ef11a238..5927c405c 100644 --- a/src/lib/components/DatabaseLinks.svelte +++ b/src/lib/components/DatabaseLinks.svelte @@ -3,6 +3,7 @@ import Clickhouse from './svg/databases/Clickhouse.svelte'; import CouchDb from './svg/databases/CouchDB.svelte'; import MongoDb from './svg/databases/MongoDB.svelte'; + import MariaDb from './svg/databases/MariaDB.svelte'; import MySql from './svg/databases/MySQL.svelte'; import PostgreSql from './svg/databases/PostgreSQL.svelte'; import Redis from './svg/databases/Redis.svelte'; @@ -17,6 +18,8 @@ {:else if database.type === 'mysql'} + {:else if database.type === 'mariadb'} + {:else if database.type === 'postgresql'} {:else if database.type === 'redis'} diff --git a/src/lib/components/common.ts b/src/lib/components/common.ts index d6ff2f8ea..b854fe623 100644 --- a/src/lib/components/common.ts +++ b/src/lib/components/common.ts @@ -52,6 +52,12 @@ export const supportedDatabaseTypesAndVersions = [ versions: ['5.0', '4.4', '4.2'] }, { name: 'mysql', fancyName: 'MySQL', baseImage: 'bitnami/mysql', versions: ['8.0', '5.7'] }, + { + name: 'mariadb', + fancyName: 'MariaDB', + baseImage: 'bitnami/mariadb', + versions: ['10.7', '10.6', '10.5', '10.4', '10.3', '10.2'] + }, { name: 'postgresql', fancyName: 'PostgreSQL', diff --git a/src/lib/components/svg/databases/MariaDB.svelte b/src/lib/components/svg/databases/MariaDB.svelte new file mode 100644 index 000000000..cb83268f1 --- /dev/null +++ b/src/lib/components/svg/databases/MariaDB.svelte @@ -0,0 +1,10 @@ + + + + + diff --git a/src/lib/database/common.ts b/src/lib/database/common.ts index 314f77b08..e83308878 100644 --- a/src/lib/database/common.ts +++ b/src/lib/database/common.ts @@ -127,60 +127,73 @@ export function getServiceImages(type: string): string[] { export function generateDatabaseConfiguration(database: Database & { settings: DatabaseSettings }): | { - volume: string; - image: string; - ulimits: Record; - privatePort: number; - environmentVariables: { - MYSQL_DATABASE: string; - MYSQL_PASSWORD: string; - MYSQL_ROOT_USER: string; - MYSQL_USER: string; - MYSQL_ROOT_PASSWORD: string; - }; - } + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + MYSQL_DATABASE: string; + MYSQL_PASSWORD: string; + MYSQL_ROOT_USER: string; + MYSQL_USER: string; + MYSQL_ROOT_PASSWORD: string; + }; + } | { - volume: string; - image: string; - ulimits: Record; - privatePort: number; - environmentVariables: { - MONGODB_ROOT_USER: string; - MONGODB_ROOT_PASSWORD: string; - }; - } + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + MONGODB_ROOT_USER: string; + MONGODB_ROOT_PASSWORD: string; + }; + } | { - volume: string; - image: string; - ulimits: Record; - privatePort: number; - environmentVariables: { - POSTGRESQL_POSTGRES_PASSWORD: string; - POSTGRESQL_USERNAME: string; - POSTGRESQL_PASSWORD: string; - POSTGRESQL_DATABASE: string; - }; - } + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + MARIADB_ROOT_USER: string; + MARIADB_ROOT_PASSWORD: string; + MARIADB_USER: string; + MARIADB_PASSWORD: string; + MARIADB_DATABASE: string; + }; + } | { - volume: string; - image: string; - ulimits: Record; - privatePort: number; - environmentVariables: { - REDIS_AOF_ENABLED: string; - REDIS_PASSWORD: string; - }; - } + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + POSTGRESQL_POSTGRES_PASSWORD: string; + POSTGRESQL_USERNAME: string; + POSTGRESQL_PASSWORD: string; + POSTGRESQL_DATABASE: string; + }; + } | { - volume: string; - image: string; - ulimits: Record; - privatePort: number; - environmentVariables: { - COUCHDB_PASSWORD: string; - COUCHDB_USER: string; - }; - } { + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + REDIS_AOF_ENABLED: string; + REDIS_PASSWORD: string; + }; + } + | { + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + COUCHDB_PASSWORD: string; + COUCHDB_USER: string; + }; + } { const { id, dbUser, @@ -207,6 +220,20 @@ export function generateDatabaseConfiguration(database: Database & { settings: D volume: `${id}-${type}-data:/bitnami/mysql/data`, ulimits: {} }; + } else if (type === 'mariadb') { + return { + privatePort: 3306, + environmentVariables: { + MARIADB_ROOT_USER: rootUser, + MARIADB_ROOT_PASSWORD: rootUserPassword, + MARIADB_USER: dbUser, + MARIADB_PASSWORD: dbUserPassword, + MARIADB_DATABASE: defaultDatabase + }, + image: `${baseImage}:${version}`, + volume: `${id}-${type}-data:/bitnami/mariadb`, + ulimits: {} + }; } else if (type === 'mongodb') { return { privatePort: 27017, diff --git a/src/lib/database/databases.ts b/src/lib/database/databases.ts index 388047ac3..edc15c729 100644 --- a/src/lib/database/databases.ts +++ b/src/lib/database/databases.ts @@ -184,6 +184,10 @@ export async function updatePasswordInDb(database, user, newPassword, isRoot) { await asyncExecShell( `DOCKER_HOST=${host} docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"ALTER USER '${user}'@'%' IDENTIFIED WITH caching_sha2_password BY '${newPassword}';\"` ); + } else if (type === 'mariadb') { + await asyncExecShell( + `DOCKER_HOST=${host} docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"SET PASSWORD FOR '${user}'@'%' = PASSWORD('${newPassword}');\"` + ); } else if (type === 'postgresql') { if (isRoot) { await asyncExecShell( diff --git a/src/routes/databases/[id]/_Databases/_Databases.svelte b/src/routes/databases/[id]/_Databases/_Databases.svelte index 1034a3543..b40cfb345 100644 --- a/src/routes/databases/[id]/_Databases/_Databases.svelte +++ b/src/routes/databases/[id]/_Databases/_Databases.svelte @@ -11,6 +11,7 @@ import MySql from './_MySQL.svelte'; import MongoDb from './_MongoDB.svelte'; + import MariaDb from './_MariaDB.svelte'; import PostgreSql from './_PostgreSQL.svelte'; import Redis from './_Redis.svelte'; import CouchDb from './_CouchDb.svelte'; @@ -190,6 +191,8 @@ {:else if database.type === 'mongodb'} + {:else if database.type === 'mariadb'} + {:else if database.type === 'redis'} {:else if database.type === 'couchdb'} diff --git a/src/routes/databases/[id]/_Databases/_MariaDB.svelte b/src/routes/databases/[id]/_Databases/_MariaDB.svelte new file mode 100644 index 000000000..3bb135421 --- /dev/null +++ b/src/routes/databases/[id]/_Databases/_MariaDB.svelte @@ -0,0 +1,79 @@ + + +
+
MariaDB
+
+
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
diff --git a/src/routes/databases/[id]/configuration/type.svelte b/src/routes/databases/[id]/configuration/type.svelte index a73163058..fadba1365 100644 --- a/src/routes/databases/[id]/configuration/type.svelte +++ b/src/routes/databases/[id]/configuration/type.svelte @@ -37,6 +37,7 @@ import Clickhouse from '$lib/components/svg/databases/Clickhouse.svelte'; import CouchDB from '$lib/components/svg/databases/CouchDB.svelte'; import MongoDB from '$lib/components/svg/databases/MongoDB.svelte'; + import MariaDB from '$lib/components/svg/databases/MariaDB.svelte'; import MySQL from '$lib/components/svg/databases/MySQL.svelte'; import PostgreSQL from '$lib/components/svg/databases/PostgreSQL.svelte'; import Redis from '$lib/components/svg/databases/Redis.svelte'; @@ -68,6 +69,8 @@ {:else if type.name === 'mongodb'} + {:else if type.name === 'mariadb'} + {:else if type.name === 'mysql'} {:else if type.name === 'postgresql'} diff --git a/src/routes/databases/index.svelte b/src/routes/databases/index.svelte index 6717ac88a..ec6b86291 100644 --- a/src/routes/databases/index.svelte +++ b/src/routes/databases/index.svelte @@ -3,6 +3,7 @@ import Clickhouse from '$lib/components/svg/databases/Clickhouse.svelte'; import CouchDB from '$lib/components/svg/databases/CouchDB.svelte'; import MongoDB from '$lib/components/svg/databases/MongoDB.svelte'; + import MariaDB from '$lib/components/svg/databases/MariaDB.svelte'; import MySQL from '$lib/components/svg/databases/MySQL.svelte'; import PostgreSQL from '$lib/components/svg/databases/PostgreSQL.svelte'; import Redis from '$lib/components/svg/databases/Redis.svelte'; @@ -66,6 +67,8 @@ {:else if database.type === 'mysql'} + {:else if database.type === 'mariadb'} + {:else if database.type === 'postgresql'} {:else if database.type === 'redis'} @@ -98,6 +101,8 @@ {:else if database.type === 'mongodb'} + {:else if database.type === 'mariadb'} + {:else if database.type === 'mysql'} {:else if database.type === 'postgresql'}