#438: Fixed docker version crashes

This commit is contained in:
frikky
2021-07-19 01:58:36 +02:00
parent 229d38fd73
commit a120561744
3 changed files with 38 additions and 35 deletions
+1
View File
@@ -33,6 +33,7 @@ FRONTEND_PORT_HTTPS=3443
# CHANGE THIS IF YOU WANT GOOD LOCAL EXECUTIONS: # CHANGE THIS IF YOU WANT GOOD LOCAL EXECUTIONS:
OUTER_HOSTNAME=shuffle-backend OUTER_HOSTNAME=shuffle-backend
DB_LOCATION=./shuffle-database 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. # Proxy configurations. SHUFFLE_PASS_WORKER_PROXY must be FALSE to not pass the proxy information to sub-apps.
# PS: It will skip proxy for # PS: It will skip proxy for
+36 -34
View File
@@ -262,45 +262,47 @@ func buildImageMemory(fs billy.Filesystem, tags []string, dockerfileFolder strin
//log.Printf("Response: %#v", imageBuildResponse.Body) //log.Printf("Response: %#v", imageBuildResponse.Body)
log.Printf("[DEBUG] IMAGERESPONSE: %#v", imageBuildResponse.Body) log.Printf("[DEBUG] IMAGERESPONSE: %#v", imageBuildResponse.Body)
//defer imageBuildResponse.Body.Close() if imageBuildResponse.Body != nil {
buildBuf := new(strings.Builder) defer imageBuildResponse.Body.Close()
_, newerr := io.Copy(buildBuf, imageBuildResponse.Body) buildBuf := new(strings.Builder)
if newerr != nil { _, newerr := io.Copy(buildBuf, imageBuildResponse.Body)
log.Printf("[WARNING] Failed reading Docker build STDOUT: %s", newerr) if newerr != nil {
} else { log.Printf("[WARNING] Failed reading Docker build STDOUT: %s", newerr)
log.Printf("[INFO] STRING: %s", buildBuf.String()) } else {
if strings.Contains(buildBuf.String(), "errorDetail") { log.Printf("[INFO] STRING: %s", buildBuf.String())
log.Printf("[ERROR] Docker build:\n%s\nERROR ABOVE: Trying to pull tags from: %s", buildBuf.String(), strings.Join(tags, "\n")) 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 // Handles pulling of the same image if applicable
// This fixes some issues with older versions of Docker which can't build // This fixes some issues with older versions of Docker which can't build
// on their own ( <17.05 ) // on their own ( <17.05 )
pullOptions := types.ImagePullOptions{} pullOptions := types.ImagePullOptions{}
downloaded := false downloaded := false
for _, image := range tags { for _, image := range tags {
// Is this ok? Not sure. Tags shouldn't be controlled here prolly. // Is this ok? Not sure. Tags shouldn't be controlled here prolly.
image = strings.ToLower(image) image = strings.ToLower(image)
newImage := fmt.Sprintf("%s/%s", registryName, image) newImage := fmt.Sprintf("%s/%s", registryName, image)
log.Printf("[INFO] Pulling image %s", newImage) log.Printf("[INFO] Pulling image %s", newImage)
reader, err := client.ImagePull(ctx, newImage, pullOptions) reader, err := client.ImagePull(ctx, newImage, pullOptions)
if err != nil { if err != nil {
log.Printf("[ERROR] Failed getting image %s: %s", newImage, err) log.Printf("[ERROR] Failed getting image %s: %s", newImage, err)
continue 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... if !downloaded {
return errors.New(fmt.Sprintf("Failed to build / download images %s", strings.Join(tags, ",")))
//newBuf := buildBuf }
downloaded = true //baseDockerName
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
} }
} }
+1 -1
View File
@@ -53,7 +53,7 @@ services:
- ORG_ID=${ORG_ID} - ORG_ID=${ORG_ID}
- ENVIRONMENT_NAME=${ENVIRONMENT_NAME} - ENVIRONMENT_NAME=${ENVIRONMENT_NAME}
- BASE_URL=http://${OUTER_HOSTNAME}:${BACKEND_PORT} - 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_NAME=${SHUFFLE_BASE_IMAGE_NAME}
- SHUFFLE_BASE_IMAGE_REGISTRY=${SHUFFLE_BASE_IMAGE_REGISTRY} - SHUFFLE_BASE_IMAGE_REGISTRY=${SHUFFLE_BASE_IMAGE_REGISTRY}
- SHUFFLE_BASE_IMAGE_TAG_SUFFIX=${SHUFFLE_BASE_IMAGE_TAG_SUFFIX} - SHUFFLE_BASE_IMAGE_TAG_SUFFIX=${SHUFFLE_BASE_IMAGE_TAG_SUFFIX}