Example #1
0
func buildBuilder() {
	image_name := config.GetProjectImage()

	builder_image_name := fmt.Sprintf("%s-builder", image_name)

	fmt.Printf("INFO: %s %s\n\n",
		"Found Dockerfile.builder, building image builder",
		builder_image_name)

	// Build builder image
	cmd_string := fmt.Sprintf("docker build -f Dockerfile.builder -t '%s' .", builder_image_name)
	cmd := exec.Command("sh", "-c", cmd_string)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err := cmd.Run()

	version := strings.TrimLeft(config.GetProjectVersion(), "v")
	fmt.Printf("INFO: Adding env variable VERSION=%s\n\n", version)
	utils.DockerImageAddEnv(builder_image_name, "VERSION", version)

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	fmt.Printf("\nINFO: %s %s\n\n",
		"Building image with builder",
		image_name)

	// Build image
	cmd_string = fmt.Sprintf("docker run --rm '%s' | docker build -t '%s' -", builder_image_name, image_name)
	cmd = exec.Command("sh", "-c", cmd_string)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err = cmd.Run()

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	fmt.Printf("INFO: Adding env variable VERSION=%s\n\n", version)
	utils.DockerImageAddEnv(image_name, "VERSION", version)
}
Example #2
0
func buildSimple() {
	image_name := config.GetProjectImage()

	fmt.Printf("INFO: %s %s\n\n",
		"Found Dockerfile, building image",
		image_name)

	cmd_string := fmt.Sprintf("docker build -t '%s' .", image_name)
	cmd := exec.Command("sh", "-c", cmd_string)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err := cmd.Run()

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	version := strings.TrimLeft(config.GetProjectVersion(), "v")
	fmt.Printf("INFO: Adding env variable VERSION=%s\n\n", version)
	utils.DockerImageAddEnv(image_name, "VERSION", version)
}