Exemple #1
0
func GetRunBaseImage(project string, serviceName string) (string, error) {
	filePath := GetDockerfilePath(project, serviceName)

	path, err := util.ReadLineRegexp(filePath, `^\s*FROM\s+(\S+)`)
	if err != nil {
		return "", err
	}
	return path, nil
}
Exemple #2
0
func GetBuildCmd(project string, serviceName string) (string, error) {
	filePath := GetBuildfilePath(project, serviceName)

	cmd, err := util.ReadLineRegexp(filePath, `^\s*RUN\s+(.*)$`)
	if err != nil {
		return "", err
	}

	cmd = strings.TrimSpace(cmd)
	cmd = strings.Replace(cmd, "\t", " ", -1)

	if strings.HasPrefix(cmd, "\"") && strings.HasSuffix(cmd, "\"") {
		cmd = strings.TrimPrefix(cmd, "\"")
		cmd = strings.TrimSuffix(cmd, "\"")
	}

	cmd = strings.Replace(cmd, "\\", "\\\\", -1) // convert \ to \\ .
	cmd = strings.Replace(cmd, "\"", "\\\"", -1) // convert " to \" .

	return cmd, nil
}