func (c *Container) Pull(done chan bool) { util.PrintGreen("Pulling", c.Image, "...") // prebuild type is deprecated if c.Type == "prebuild" { util.PrintRed("WARN: 'prebuild' type is deprecated, use 'index' instead") } docker.Pull(c.Image) done <- true }
func (maestro *Maestro) Start() { maestro.parseTemplates() nbApplications := len(maestro.Applications) cleanChans := make(chan bool, nbApplications) hasGaudiManagedContainer := false // Clean all applications for _, currentContainer := range maestro.Applications { if currentContainer.IsGaudiManaged() { hasGaudiManagedContainer = true } go currentContainer.Clean(cleanChans) } <-cleanChans buildChans := make(chan bool, len(maestro.Applications)) // Check if base image is pulled if hasGaudiManagedContainer && !docker.ImageExists(DEFAULT_BASE_IMAGE) { fmt.Println("Pulling base image (this may take a few minutes) ...") docker.Pull(DEFAULT_BASE_IMAGE_WITH_TAG) } // Build all applications for _, currentContainer := range maestro.Applications { if currentContainer.IsPreBuild() { go currentContainer.Pull(buildChans) } else { go currentContainer.Build(buildChans) } } for i := 0; i < nbApplications; i++ { <-buildChans } startChans := make(map[string]chan bool) // Start all applications for name, currentContainer := range maestro.Applications { startChans[name] = make(chan bool) go maestro.startContainer(currentContainer, startChans) } // Waiting for all applications to start for containerName, _ := range maestro.Applications { <-startChans[containerName] } }
func (gaudi *Gaudi) Init(content string) { err := goyaml.Unmarshal([]byte(content), &gaudi) if err != nil { util.LogError(err) } emptyCmdForContainers = strings.Split(*emptyCmdFlag, ",") // Init all containers gaudi.Applications.AddAmbassadors() gaudi.All = containerCollection.Merge(gaudi.Applications, gaudi.Binaries) if len(gaudi.All) == 0 { util.LogError("No application or binary to start. Are you missing a 'applications' or 'binaries' field in your configuration ?") } hasGaudiManagedContainer := gaudi.All.Init(gaudi.ApplicationDir) // Apply extends gaudi.applyInheritance() // Check if docker is installed if !docker.HasDocker() { util.LogError("Docker should be installed to use Gaudi (see: https://www.docker.io/gettingstarted/).") } // Check if base image is pulled if hasGaudiManagedContainer && !docker.ImageExists(DEFAULT_BASE_IMAGE) { util.PrintGreen("Pulling base image (this may take a few minutes) ...") docker.Pull(DEFAULT_BASE_IMAGE_WITH_TAG) } if gaudi.useNewVersion() { os.RemoveAll(TEMPLATE_DIR) } // Check if templates are present if !util.IsDir(TEMPLATE_DIR) { util.PrintGreen("Retrieving templates ...") retrieveTemplates() extractTemplates() } gaudi.build() }
func (c *Container) Pull(done chan bool) { fmt.Println("Pulling", c.Image, "...") docker.Pull(c.Image) done <- true }