diff --git a/docker/generate/compose/src/main.go b/docker/generate/compose/src/main.go index 0cc3f289..c6e89120 100644 --- a/docker/generate/compose/src/main.go +++ b/docker/generate/compose/src/main.go @@ -9,7 +9,7 @@ func main() { var selectItems []string selectItem := "" var extParams = make(map[string]string) - items := []string{"awsclivl", "consul", "dynamoDB", "jaeger", "kafka", "mongo", "postgres", "redis", "stubby4j", "rabbitmq", "finish!"} + items := []string{"awsclivl", "consul", "dynamoDB", "jaeger", "kafka", "mongo", "postgres", "mysql", "redis", "stubby4j", "rabbitmq", "finish!"} for selectItem != "finish!" { selectItem, _ = prompt.List("Select docker image: ", items) if selectItem == "postgres" { @@ -17,6 +17,11 @@ func main() { extParams["postgresUser"], _ = prompt.String("Type DB user: ", true) extParams["postgresPassword"], _ = prompt.StringPwd("Type DB password: ") } + if selectItem == "mysql" { + extParams["mysqlDB"], _ = prompt.String("Type DB name: ", true) + extParams["mysqlUser"], _ = prompt.String("Type DB user: ", true) + extParams["mysqlPassword"], _ = prompt.StringPwd("Type DB password: ") + } if selectItem == "mongo" { extParams["mongoWebClientUser"], _ = prompt.String("Type Mongo WebClient user: ", true) extParams["mongoWebClientPassword"], _ = prompt.StringPwd("Type Mongo WebClient password: ") diff --git a/docker/generate/compose/src/pkg/compose/compose.go b/docker/generate/compose/src/pkg/compose/compose.go index a7838263..fc44cf2d 100644 --- a/docker/generate/compose/src/pkg/compose/compose.go +++ b/docker/generate/compose/src/pkg/compose/compose.go @@ -51,6 +51,15 @@ services:` - POSTGRES_PASSWORD={{POSTGRES_PASSWORD}} - MAX_CONNECTIONS=300` + mysqlYml = ` mysql: + image: mysql:8.0 + ports: + - "3307:3306" + environment: + - MYSQL_DATABASE={{MYSQL_DB}} + - MYSQL_USER={{MYSQL_USER}} + - MYSQL_ROOT_PASSWORD={{MYSQL_PASSWORD}}` + mongoYml = ` mongo: image: mongo restart: always @@ -163,6 +172,12 @@ func GenerateYml(items []string, extParams map[string]string) { postgresYmlString = strings.Replace(postgresYmlString, "{{POSTGRES_USER}}", extParams["postgresUser"], -1) postgresYmlString = strings.Replace(postgresYmlString, "{{POSTGRES_PASSWORD}}", extParams["postgresPassword"], -1) ymlString = fmt.Sprintf("%s%s\n\n", ymlString, postgresYmlString) + case "mysql": + mysqlYmlString := mysqlYml + mysqlYmlString = strings.Replace(mysqlYmlString, "{{MYSQL_DB}}", extParams["mysqlDB"], -1) + mysqlYmlString = strings.Replace(mysqlYmlString, "{{MYSQL_USER}}", extParams["mysqlUser"], -1) + mysqlYmlString = strings.Replace(mysqlYmlString, "{{MYSQL_PASSWORD}}", extParams["mysqlPassword"], -1) + ymlString = fmt.Sprintf("%s%s\n\n", ymlString, mysqlYmlString) case "mongo": mongoYmlString := mongoYml mongoYmlString = strings.Replace(mongoYmlString, "{{MONGO_WEBCLIENT_USER}}", extParams["mongoWebClientUser"], -1)