Use cache correctly
This commit is contained in:
parent
500ce50153
commit
2f596f739d
@ -6,18 +6,28 @@
|
|||||||
TAG=$(echo "${BRANCH_NAME}" | sed -e "s/\//_/g")
|
TAG=$(echo "${BRANCH_NAME}" | sed -e "s/\//_/g")
|
||||||
PI_PLATFORM="linux/arm/v7"
|
PI_PLATFORM="linux/arm/v7"
|
||||||
echo "Running for ${TAG}"
|
echo "Running for ${TAG}"
|
||||||
|
CACHE_TAG=${IMAGE_NAME}:${TAG}_cache
|
||||||
|
|
||||||
# Add commit and commit_message to docker container
|
# Add commit and commit_message to docker container
|
||||||
echo "${GITHUB_SHA}" > freqtrade_commit
|
echo "${GITHUB_SHA}" > freqtrade_commit
|
||||||
|
|
||||||
if [ "${GITHUB_EVENT_NAME}" = "schedule" ]; then
|
if [ "${GITHUB_EVENT_NAME}" = "schedule" ]; then
|
||||||
echo "event ${GITHUB_EVENT_NAME}: full rebuild - skipping cache"
|
echo "event ${GITHUB_EVENT_NAME}: full rebuild - skipping cache"
|
||||||
docker buildx build -f Dockerfile.armhf --platform ${PI_PLATFORM} -t ${IMAGE_NAME}:${TAG} --push .
|
docker buildx build \
|
||||||
|
--cache-to=type=registry,ref=${CACHE_TAG} \
|
||||||
|
-f Dockerfile.armhf \
|
||||||
|
--platform ${PI_PLATFORM} \
|
||||||
|
-t ${IMAGE_NAME}:${TAG} --push .
|
||||||
else
|
else
|
||||||
echo "event ${GITHUB_EVENT_NAME}: building with cache"
|
echo "event ${GITHUB_EVENT_NAME}: building with cache"
|
||||||
# Pull last build to avoid rebuilding the whole image
|
# Pull last build to avoid rebuilding the whole image
|
||||||
# docker pull --platform ${PI_PLATFORM} ${IMAGE_NAME}:${TAG}
|
# docker pull --platform ${PI_PLATFORM} ${IMAGE_NAME}:${TAG}
|
||||||
docker buildx build --cache-from=type=registry,ref=${IMAGE_NAME}:${TAG} -f Dockerfile.armhf --platform ${PI_PLATFORM} -t ${IMAGE_NAME}:${TAG} --push .
|
docker buildx build \
|
||||||
|
--cache-from=type=registry,ref=${CACHE_TAG} \
|
||||||
|
--cache-to=type=registry,ref=${CACHE_TAG} \
|
||||||
|
-f Dockerfile.armhf \
|
||||||
|
--platform ${PI_PLATFORM} \
|
||||||
|
-t ${IMAGE_NAME}:${TAG} --push .
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user