How do I handle Docker Hub build caching with a buildx hook

23 views Asked by At

I am building multiarch images on Docker Hub using buildx and wrote simple hooks for this.

As i am currently building a Next.JS Application, i noticed that subsequent builds using the same package-lock are not using the cache, which they do on local builds.

These are my current hooks:

build

#!/bin/bash

docker buildx create --name multiarch --use
docker buildx build -t $IMAGE_NAME --platform linux/amd64,linux/arm64 --push .

push

#!/bin/bash
# Just echo a Hello World message
echo "Image already pushed to Docker Hub (by buildx)"

Note i overwrote the push hook because Docker Hub wasn't able to find any image on that step.

My Questions are: How can i implement caching in these hooks? Is the push hook necessary? How can i handle this in a more graceful way - preferably without overriding Docker Hub's default behaviour?

0

There are 0 answers