Browse Source

feat: mysql分成两个应用

pull/35/head
zhengkunwang223 2 years ago committed by zhengkunwang223
parent
commit
7dad47464d
  1. 22
      apps/list.json
  2. 0
      apps/mysql5.7/5.7.39/README.md
  3. 0
      apps/mysql5.7/5.7.39/conf/my.cnf
  4. 0
      apps/mysql5.7/5.7.39/config.json
  5. 0
      apps/mysql5.7/5.7.39/docker-compose.yml
  6. 0
      apps/mysql8.0/8.0.30/README.md
  7. 0
      apps/mysql8.0/8.0.30/conf/my.cnf
  8. 0
      apps/mysql8.0/8.0.30/config.json
  9. 0
      apps/mysql8.0/8.0.30/docker-compose.yml
  10. 10
      apps/nginx/1.23.1/conf/nginx.conf
  11. 24
      backend/app/service/app_utils.go

22
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"
},
{

0
apps/mysql/5.7.39/README.md → apps/mysql5.7/5.7.39/README.md

0
apps/mysql/5.7.39/conf/my.cnf → apps/mysql5.7/5.7.39/conf/my.cnf

0
apps/mysql/5.7.39/config.json → apps/mysql5.7/5.7.39/config.json

0
apps/mysql/5.7.39/docker-compose.yml → apps/mysql5.7/5.7.39/docker-compose.yml

0
apps/mysql/8.0.30/README.md → apps/mysql8.0/8.0.30/README.md

0
apps/mysql/8.0.30/conf/my.cnf → apps/mysql8.0/8.0.30/conf/my.cnf

0
apps/mysql/8.0.30/config.json → apps/mysql8.0/8.0.30/config.json

0
apps/mysql/8.0.30/docker-compose.yml → apps/mysql8.0/8.0.30/docker-compose.yml

10
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;
}
}
}

24
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;\" ",

Loading…
Cancel
Save