From 7dad47464d97ad3ab7e144082089d9c6b7a13d51 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Mon, 24 Oct 2022 17:46:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mysql=E5=88=86=E6=88=90=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/list.json | 22 +++++++++++++---- apps/{mysql => mysql5.7}/5.7.39/README.md | 0 apps/{mysql => mysql5.7}/5.7.39/conf/my.cnf | 0 apps/{mysql => mysql5.7}/5.7.39/config.json | 0 .../5.7.39/docker-compose.yml | 0 apps/{mysql => mysql8.0}/8.0.30/README.md | 0 apps/{mysql => mysql8.0}/8.0.30/conf/my.cnf | 0 apps/{mysql => mysql8.0}/8.0.30/config.json | 0 .../8.0.30/docker-compose.yml | 0 apps/nginx/1.23.1/conf/nginx.conf | 10 ++++++++ backend/app/service/app_utils.go | 24 +++++++++++-------- 11 files changed, 42 insertions(+), 14 deletions(-) rename apps/{mysql => mysql5.7}/5.7.39/README.md (100%) rename apps/{mysql => mysql5.7}/5.7.39/conf/my.cnf (100%) rename apps/{mysql => mysql5.7}/5.7.39/config.json (100%) rename apps/{mysql => mysql5.7}/5.7.39/docker-compose.yml (100%) rename apps/{mysql => mysql8.0}/8.0.30/README.md (100%) rename apps/{mysql => mysql8.0}/8.0.30/conf/my.cnf (100%) rename apps/{mysql => mysql8.0}/8.0.30/config.json (100%) rename apps/{mysql => mysql8.0}/8.0.30/docker-compose.yml (100%) diff --git a/apps/list.json b/apps/list.json index abded4bbf..2225836ac 100644 --- a/apps/list.json +++ b/apps/list.json @@ -16,17 +16,31 @@ ], "items": [ { - "key": "mysql", - "name": "Mysql", + "key": "mysql5.7", + "name": "Mysql5.7", "tags": ["Datastore"], - "versions": ["5.7.39","8.0.30"], + "versions": ["5.7.39"], "short_desc": "常用关系型数据库", "icon": "mysql.png", "author": "Oracle", "type": "runtime", "required": [""], "crossVersionUpdate": false, - "limit": 0, + "limit": 1, + "source": "https://www.mysql.com" + }, + { + "key": "mysql8.0", + "name": "Mysql8.0", + "tags": ["Datastore"], + "versions": ["8.0.30"], + "short_desc": "常用关系型数据库", + "icon": "mysql.png", + "author": "Oracle", + "type": "runtime", + "required": [""], + "crossVersionUpdate": false, + "limit": 1, "source": "https://www.mysql.com" }, { diff --git a/apps/mysql/5.7.39/README.md b/apps/mysql5.7/5.7.39/README.md similarity index 100% rename from apps/mysql/5.7.39/README.md rename to apps/mysql5.7/5.7.39/README.md diff --git a/apps/mysql/5.7.39/conf/my.cnf b/apps/mysql5.7/5.7.39/conf/my.cnf similarity index 100% rename from apps/mysql/5.7.39/conf/my.cnf rename to apps/mysql5.7/5.7.39/conf/my.cnf diff --git a/apps/mysql/5.7.39/config.json b/apps/mysql5.7/5.7.39/config.json similarity index 100% rename from apps/mysql/5.7.39/config.json rename to apps/mysql5.7/5.7.39/config.json diff --git a/apps/mysql/5.7.39/docker-compose.yml b/apps/mysql5.7/5.7.39/docker-compose.yml similarity index 100% rename from apps/mysql/5.7.39/docker-compose.yml rename to apps/mysql5.7/5.7.39/docker-compose.yml diff --git a/apps/mysql/8.0.30/README.md b/apps/mysql8.0/8.0.30/README.md similarity index 100% rename from apps/mysql/8.0.30/README.md rename to apps/mysql8.0/8.0.30/README.md diff --git a/apps/mysql/8.0.30/conf/my.cnf b/apps/mysql8.0/8.0.30/conf/my.cnf similarity index 100% rename from apps/mysql/8.0.30/conf/my.cnf rename to apps/mysql8.0/8.0.30/conf/my.cnf diff --git a/apps/mysql/8.0.30/config.json b/apps/mysql8.0/8.0.30/config.json similarity index 100% rename from apps/mysql/8.0.30/config.json rename to apps/mysql8.0/8.0.30/config.json diff --git a/apps/mysql/8.0.30/docker-compose.yml b/apps/mysql8.0/8.0.30/docker-compose.yml similarity index 100% rename from apps/mysql/8.0.30/docker-compose.yml rename to apps/mysql8.0/8.0.30/docker-compose.yml diff --git a/apps/nginx/1.23.1/conf/nginx.conf b/apps/nginx/1.23.1/conf/nginx.conf index 49d3efc23..767ac2dcf 100644 --- a/apps/nginx/1.23.1/conf/nginx.conf +++ b/apps/nginx/1.23.1/conf/nginx.conf @@ -23,4 +23,14 @@ http { keepalive_timeout 65; include /etc/nginx/conf.d/*.conf; + + server { + listen 80; + server_name 127.0.0.1; + allow 127.0.0.1; + location /nginx_status { + stub_status on; + access_log off; + } + } } \ No newline at end of file diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 45736f49e..ba156272b 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -46,26 +46,30 @@ func execDockerCommand(database model.AppDatabase, dbInstall model.AppInstall, o Auth: auth, DbParam: dbConfig, } - _, err := cmd.Exec(getSqlStr(database.Key, dbInstall.Version, op, execConfig)) + _, err := cmd.Exec(getSqlStr(database.Key, op, execConfig)) if err != nil { return err } return nil } -func getSqlStr(key, version string, operate DatabaseOp, exec dto.ContainerExec) string { +func getSqlStr(key string, operate DatabaseOp, exec dto.ContainerExec) string { var str string param := exec.DbParam switch key { - case "mysql": + case "mysql5.7": if operate == Add { - if common.CompareVersion(version, "8.0") { - str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%';\" -e \"FLUSH PRIVILEGES;\"", - exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser) - } else { - str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';\" -e \"FLUSH PRIVILEGES;\"", - exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser, param.Password) - } + str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';\" -e \"FLUSH PRIVILEGES;\"", + exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser, param.Password) + } + if operate == Delete { + str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"drop database %s;\" -e \"drop user %s;\" ", + exec.ContainerName, exec.Auth.RootPassword, param.DbName, param.DbUser) + } + case "mysql8.0": + if operate == Add { + str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%';\" -e \"FLUSH PRIVILEGES;\"", + exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser) } if operate == Delete { str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"drop database %s;\" -e \"drop user %s;\" ",