Skip to content

Commit

Permalink
update check on docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
vvalerio-priv committed Mar 7, 2024
1 parent adda1d8 commit 10e9eed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 23 additions & 4 deletions cmd/methods/createfunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package methods

import (
"fmt"
"os"
"os/exec"
"regexp"
Expand All @@ -29,9 +30,23 @@ import (

func CreateEnvironment(env string, dockercomposefile string, externalip string, envname string, envtag string, update string, autoupdate string) error {

out, err := exec.Command("docker", "compose", "version").Output()
dockercommand := "docker"
composecommand := "compose"
if err != nil {
PrintNotification("No valid Docker Compose command found, try with docker-compose command")
out, err = exec.Command("docker-compose", "version").Output()
if err != nil {
PrintError("No valid docker and docker-compose installation found")
return err
}
dockercommand = "docker-compose"
composecommand = ""
}
if update != "true" && update != "false" {
update = "false"
}
fmt.Println(string(out))

envtagname := ""

Expand Down Expand Up @@ -108,7 +123,8 @@ func CreateEnvironment(env string, dockercomposefile string, externalip string,

PrintTask("Installing rabbitmq container on the machine")

if err := ExecuteCommand(exec.Command("docker-compose",
if err := ExecuteCommand(exec.Command(dockercommand,
composecommand,
"-f",
dockercomposefile,
"--env-file="+env,
Expand All @@ -125,7 +141,8 @@ func CreateEnvironment(env string, dockercomposefile string, externalip string,

PrintTask("Installing metadata catalogue container on the machine")

if err := ExecuteCommand(exec.Command("docker-compose",
if err := ExecuteCommand(exec.Command(dockercommand,
composecommand,
"-f",
dockercomposefile,
"--env-file="+env,
Expand All @@ -142,7 +159,8 @@ func CreateEnvironment(env string, dockercomposefile string, externalip string,

PrintTask("Installing all remaining containers on the machine")

if err := ExecuteCommand(exec.Command("docker-compose",
if err := ExecuteCommand(exec.Command(dockercommand,
composecommand,
"-f",
dockercomposefile,
"--env-file="+env,
Expand All @@ -157,7 +175,8 @@ func CreateEnvironment(env string, dockercomposefile string, externalip string,
PrintWait("Waiting for the containers to be up and running...")
time.Sleep(40 * time.Second)
PrintTask("Restarting gateway")
if err := ExecuteCommand(exec.Command("docker-compose",
if err := ExecuteCommand(exec.Command(dockercommand,
composecommand,
"-f",
dockercomposefile,
"--env-file="+env,
Expand Down
2 changes: 1 addition & 1 deletion cmd/methods/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
package methods

func GetVersion() string {
return "1.1.4"
return "1.1.5"
}

0 comments on commit 10e9eed

Please sign in to comment.