| 66 | } |
| 67 | |
| 68 | func findComposeFile(cmd string) []string { |
| 69 | |
| 70 | cmdArgs := strings.Fields(cmd) |
| 71 | composePaths := []string{} |
| 72 | haveMultipleComposeFiles := false |
| 73 | |
| 74 | for i := 0; i < len(cmdArgs); i++ { |
| 75 | if cmdArgs[i] == "-f" && i+1 < len(cmdArgs) { |
| 76 | composePaths = append(composePaths, cmdArgs[i+1]) |
| 77 | haveMultipleComposeFiles = true |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if haveMultipleComposeFiles { |
| 82 | return composePaths |
| 83 | } |
| 84 | |
| 85 | filenames := []string{"docker-compose.yml", "docker-compose.yaml", "compose.yml", "compose.yaml"} |
| 86 | |
| 87 | for _, filename := range filenames { |
| 88 | if _, err := os.Stat(filename); !os.IsNotExist(err) { |
| 89 | return []string{filename} |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return []string{} |
| 94 | } |
| 95 | |
| 96 | func modifyDockerComposeCommand(appCmd, newComposeFile, appComposePath, appServiceName string) string { |
| 97 | // Ensure newComposeFile starts with ./ |