diff --git a/.env b/.env index be6f9de0..e10cbb18 100644 --- a/.env +++ b/.env @@ -33,6 +33,7 @@ FRONTEND_PORT_HTTPS=3443 # CHANGE THIS IF YOU WANT GOOD LOCAL EXECUTIONS: OUTER_HOSTNAME=shuffle-backend DB_LOCATION=./shuffle-database +DOCKER_API_VERSION=1.40 # Proxy configurations. SHUFFLE_PASS_WORKER_PROXY must be FALSE to not pass the proxy information to sub-apps. # PS: It will skip proxy for diff --git a/backend/go-app/docker.go b/backend/go-app/docker.go index 069a88e6..2e9a4314 100644 --- a/backend/go-app/docker.go +++ b/backend/go-app/docker.go @@ -262,45 +262,47 @@ func buildImageMemory(fs billy.Filesystem, tags []string, dockerfileFolder strin //log.Printf("Response: %#v", imageBuildResponse.Body) log.Printf("[DEBUG] IMAGERESPONSE: %#v", imageBuildResponse.Body) - //defer imageBuildResponse.Body.Close() - buildBuf := new(strings.Builder) - _, newerr := io.Copy(buildBuf, imageBuildResponse.Body) - if newerr != nil { - log.Printf("[WARNING] Failed reading Docker build STDOUT: %s", newerr) - } else { - log.Printf("[INFO] STRING: %s", buildBuf.String()) - if strings.Contains(buildBuf.String(), "errorDetail") { - log.Printf("[ERROR] Docker build:\n%s\nERROR ABOVE: Trying to pull tags from: %s", buildBuf.String(), strings.Join(tags, "\n")) + if imageBuildResponse.Body != nil { + defer imageBuildResponse.Body.Close() + buildBuf := new(strings.Builder) + _, newerr := io.Copy(buildBuf, imageBuildResponse.Body) + if newerr != nil { + log.Printf("[WARNING] Failed reading Docker build STDOUT: %s", newerr) + } else { + log.Printf("[INFO] STRING: %s", buildBuf.String()) + if strings.Contains(buildBuf.String(), "errorDetail") { + log.Printf("[ERROR] Docker build:\n%s\nERROR ABOVE: Trying to pull tags from: %s", buildBuf.String(), strings.Join(tags, "\n")) - // Handles pulling of the same image if applicable - // This fixes some issues with older versions of Docker which can't build - // on their own ( <17.05 ) - pullOptions := types.ImagePullOptions{} - downloaded := false - for _, image := range tags { - // Is this ok? Not sure. Tags shouldn't be controlled here prolly. - image = strings.ToLower(image) + // Handles pulling of the same image if applicable + // This fixes some issues with older versions of Docker which can't build + // on their own ( <17.05 ) + pullOptions := types.ImagePullOptions{} + downloaded := false + for _, image := range tags { + // Is this ok? Not sure. Tags shouldn't be controlled here prolly. + image = strings.ToLower(image) - newImage := fmt.Sprintf("%s/%s", registryName, image) - log.Printf("[INFO] Pulling image %s", newImage) - reader, err := client.ImagePull(ctx, newImage, pullOptions) - if err != nil { - log.Printf("[ERROR] Failed getting image %s: %s", newImage, err) - continue + newImage := fmt.Sprintf("%s/%s", registryName, image) + log.Printf("[INFO] Pulling image %s", newImage) + reader, err := client.ImagePull(ctx, newImage, pullOptions) + if err != nil { + log.Printf("[ERROR] Failed getting image %s: %s", newImage, err) + continue + } + + // Attempt to retag the image to not contain registry... + + //newBuf := buildBuf + downloaded = true + io.Copy(os.Stdout, reader) + log.Printf("[INFO] Successfully downloaded and built %s", newImage) } - // Attempt to retag the image to not contain registry... - - //newBuf := buildBuf - downloaded = true - io.Copy(os.Stdout, reader) - log.Printf("[INFO] Successfully downloaded and built %s", newImage) + if !downloaded { + return errors.New(fmt.Sprintf("Failed to build / download images %s", strings.Join(tags, ","))) + } + //baseDockerName } - - if !downloaded { - return errors.New(fmt.Sprintf("Failed to build / download images %s", strings.Join(tags, ","))) - } - //baseDockerName } } diff --git a/docker-compose.yml b/docker-compose.yml index 78e6ae61..69ca24b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,7 +53,7 @@ services: - ORG_ID=${ORG_ID} - ENVIRONMENT_NAME=${ENVIRONMENT_NAME} - BASE_URL=http://${OUTER_HOSTNAME}:${BACKEND_PORT} - - DOCKER_API_VERSION=1.35 + - DOCKER_API_VERSION=1.40 - SHUFFLE_BASE_IMAGE_NAME=${SHUFFLE_BASE_IMAGE_NAME} - SHUFFLE_BASE_IMAGE_REGISTRY=${SHUFFLE_BASE_IMAGE_REGISTRY} - SHUFFLE_BASE_IMAGE_TAG_SUFFIX=${SHUFFLE_BASE_IMAGE_TAG_SUFFIX}