Skip to content

Error forging the images #94

@christoph-maurer

Description

@christoph-maurer

I got errors while forging and pushing the images:

christoph@de14278:~/Documents/building-envelope-data/bed_lokal/database_lokal/development$ ./forge.mk all USER=cloud HOST=192.102.154.234 NAME=test01-database_production
make --file="forge.mk" \
        build \
        push \
        SERVICE=backend
make[1]: Entering directory '/home/christoph/Documents/building-envelope-data/bed_lokal/database_lokal/development'
if [[ "false" == "true" || -z "8eec13af1add" ]]; then \
        docker build \
                --pull \
                --file "./backend/Dockerfile.production" \
                --tag "test01-database_production-backend:226b487eaa32e995af051689240ce598ba6596c5" \
                "./backend" ; \
else \
        echo "Image already exists, skipping build. Pass `OVERWRITE=true` to build anyway." ; \
fi
Image already exists, skipping build. Pass  to build anyway.
docker save \
        --platform "linux/amd64" \
        "test01-database_production-backend:226b487eaa32e995af051689240ce598ba6596c5" \
        | bzip2 \
        | ssh "cloud@192.102.154.234" "docker load"
Loaded image: test01-database_production-backend:226b487eaa32e995af051689240ce598ba6596c5
make[1]: Leaving directory '/home/christoph/Documents/building-envelope-data/bed_lokal/database_lokal/development'
make --file="forge.mk" \
        build \
        push \
        SERVICE=frontend
make[1]: Entering directory '/home/christoph/Documents/building-envelope-data/bed_lokal/database_lokal/development'
if [[ "false" == "true" || -z "" ]]; then \
        docker build \
                --pull \
                --file "./frontend/Dockerfile.production" \
                --tag "test01-database_production-frontend:226b487eaa32e995af051689240ce598ba6596c5" \
                "./frontend" ; \
else \
        echo "Image already exists, skipping build. Pass `OVERWRITE=true` to build anyway." ; \
fi
[+] Building 133.7s (19/19) FINISHED                                           docker:default
 => [internal] load build definition from Dockerfile.production                          0.0s
 => => transferring dockerfile: 1.46kB                                                   0.0s
 => resolve image config for docker-image://docker.io/docker/dockerfile:1.21             0.7s
 => CACHED docker-image://docker.io/docker/dockerfile:1.21@sha256:27f9262d43452075f3c41  0.0s
 => [internal] load metadata for docker.io/library/node:24.11-trixie-slim                0.7s
 => [internal] load .dockerignore                                                        0.0s
 => => transferring context: 370B                                                        0.0s
 => [base 1/1] FROM docker.io/library/node:24.11-trixie-slim@sha256:4623e8ac1eb5f35b0a9  0.0s
 => [internal] load build context                                                        0.0s
 => => transferring context: 3.83kB                                                      0.0s
 => CACHED [dependencies 1/3] WORKDIR /app                                               0.0s
 => CACHED [build 2/4] COPY ./ ./                                                        0.0s
 => CACHED [dependencies 2/3] COPY ./package.json ./yarn.lock ./                         0.0s
 => CACHED [dependencies 3/3] RUN yarn install --frozen-lockfile                         0.0s
 => CACHED [build 3/4] COPY --from=dependencies /app/node_modules ./node_modules         0.0s
 => [build 4/4] RUN yarn build                                                         127.9s
 => CACHED [runtime 2/6] RUN addgroup --system --gid 1001 nodejs   && adduser --system   0.0s
 => CACHED [runtime 3/6] RUN apt-get update   && apt-get upgrade --assume-yes   && apt-  0.0s
 => [runtime 4/6] COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./       1.6s
 => [runtime 5/6] COPY --from=build --chown=nextjs:nodejs /app/public ./public           0.4s
 => [runtime 6/6] COPY --from=build --chown=nextjs:nodejs /app/.next/static ./.next/sta  0.4s
 => exporting to image                                                                   0.9s
 => => exporting layers                                                                  0.8s
 => => writing image sha256:bf6efabfeb4c487e0eca2adaf7b6c6e3b862f0c7a49276ed1a5aae6debc  0.0s
 => => naming to docker.io/library/test01-database_production-frontend:226b487eaa32e995  0.0s
docker save \
        --platform "linux/amd64" \
        "test01-database_production-frontend:226b487eaa32e995af051689240ce598ba6596c5" \
        | bzip2 \
        | ssh "cloud@192.102.154.234" "docker load"
Connection reset by 192.102.154.234 port 22
make[1]: *** [forge.mk:37: push] Error 255
make[1]: Leaving directory '/home/christoph/Documents/building-envelope-data/bed_lokal/database_lokal/development'
make: *** [forge.mk:46: all] Error 2

AI proposes

$ git diff
diff --git a/forge.mk b/forge.mk
index 8f5aa06..9467efe 100755
--- a/forge.mk
+++ b/forge.mk
@@ -29,16 +29,31 @@ build : ## Build image if it does not exist yet, for example, `./forge.mk build
                        --tag "${NAME}-${SERVICE}:${TARGET}" \
                        "./${SERVICE}" ; \
        else \
-               echo "Image already exists, skipping build. Pass `OVERWRITE=true` to build anyway." ; \
+               echo "Image already exists, skipping build. Pass \`OVERW
RITE=true\` to build anyway." ; \
        fi
 .PHONY : build
 
 push : ## Push image, for example, `./forge.mk push SERVICE=backend USE
R=cloud HOST=192.102.162.39`
-       docker save \
-               --platform "linux/amd64" \
-               "${NAME}-${SERVICE}:${TARGET}" \
-               | bzip2 \
-               | ssh "${USER}@${HOST}" "docker load"
+       @for attempt in 1 2 3; do \
+               if docker save \
+                       --platform "linux/amd64" \
+                       "${NAME}-${SERVICE}:${TARGET}" \
+                       | bzip2 \
+                       | ssh \
+                               -o "ServerAliveInterval=20" \
+                               -o "ServerAliveCountMax=6" \
+                               -o "TCPKeepAlive=yes" \
+                               -o "ConnectTimeout=15" \
+                               "${USER}@${HOST}" "docker load" ; then \
+                       echo "Push successful on attempt $${attempt}." ;
 \
+                       break ; \
+               fi ; \
+               if [[ "$${attempt}" -ge 3 ]]; then \
+                       echo "Push failed after $${attempt} attempts." >
&2 ; \
+                       exit 1 ; \
+               fi ; \
+               echo "Push failed on attempt $${attempt}. Retrying..." >
&2 ; \
+       done
 .PHONY : push
 
 all : ## Build and push all images, for example, `./forge.mk all USER=c
loud HOST=192.102.162.39`

which works. @simon-wacker shall I commit the changes?

Metadata

Metadata

Labels

2601ISEFraunhofer Institute for Solar Energy Systems ISE

Type

No type
No fields configured for issues without a type.

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions