func pullAppImages() { var log = logger.New("ns=app_images") if os.Getenv("DEVELOPMENT") == "true" { return } maxRetries := 5 var err error for i := 0; i < maxRetries; i++ { err := dockerLogin() if err == nil { break } time.Sleep(30 * time.Second) } if err != nil { return } apps, err := models.ListApps() if err != nil { log.Error(err) return } for _, app := range apps { a, err := models.GetApp(app.Name) if err != nil { log.Error(err) continue } for key, value := range a.Parameters { if strings.HasSuffix(key, "Image") { log.Log("cmd=%q", fmt.Sprintf("docker pull %s", value)) data, err := exec.Command("docker", "pull", value).CombinedOutput() if err != nil { fmt.Printf("%+v\n", string(data)) log.Error(err) continue } } } } }
func pullAppImages() { if os.Getenv("DEVELOPMENT") == "true" { return } var log = logger.New("ns=app_images") apps, err := models.ListApps() if err != nil { log.Error(err) return } log.Log("cmd=%q", fmt.Sprintf("docker login -e [email protected] -u convox -p ***** %s", os.Getenv("REGISTRY_HOST"))) data, err := exec.Command("docker", "login", "-e", "*****@*****.**", "-u", "convox", "-p", os.Getenv("PASSWORD"), os.Getenv("REGISTRY_HOST")).CombinedOutput() if err != nil { fmt.Printf("%+v\n", string(data)) log.Error(err) return } for _, app := range apps { a, err := models.GetApp(app.Name) if err != nil { log.Error(err) continue } for key, value := range a.Parameters { if strings.HasSuffix(key, "Image") { log.Log("cmd=%q", fmt.Sprintf("docker pull %s", value)) data, err := exec.Command("docker", "pull", value).CombinedOutput() if err != nil { fmt.Printf("%+v\n", string(data)) log.Error(err) continue } } } } }
func AppList(rw http.ResponseWriter, r *http.Request) { log := appsLogger("list").Start() apps, err := models.ListApps() if err != nil { helpers.Error(log, err) RenderError(rw, err) return } sort.Sort(apps) params := map[string]interface{}{ "Apps": apps, } switch r.Header.Get("Content-Type") { case "application/json": RenderJson(rw, apps) default: RenderTemplate(rw, "apps", params) } }