:::

雜談:GitHub Action的Docker映像檔分層快取不能用了... / TALK:  GitHub Action's Docker Image Layer Caching Is Broken...

9月 27, 2024 , , , 0 Comments Edit Copy Download

2024-0806-024325.png

我在GitHub Action執行CI/CD的時候所使用的Docker映像檔分層快取功能「satackey/action-docker-layer-caching@v0.0.11」,現在已經不能使用了啊。怎麽辦好呢?


2024-0806-021622.png

https://github.com/satackey/action-docker-layer-caching/blob/main/README.md 

原本這套寫法是來自於「Docker Layer Caching in GitHub Actions」的保存庫。如果有在執行docker-compose up之間加入以下設定,那麼Docker映像檔就能夠被快取,避免下次還要再下載的困擾:

- uses: satackey/action-docker-layer-caching@v0.0.11
  continue-on-error: true

2024-0806-021838.png

但此功能在很久以前就已經不能使用了。GitHub Action的錯誤訊息如下:

Warning: The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Received 0 of 1192210619 (0.0%), 0.0 MBs/sec
TypeError: this.source.on is not a function
    at module.exports.373.RetriableReadableStream.setSourceDataHandler (/home/runner/work/_actions/satackey/action-docker-layer-caching/v0.0.11/dist/ttsc-dist/main.js/index.js:21130:21)
    at new RetriableReadableStream (/home/runner/work/_actions/satackey/action-docker-layer-caching/v0.0.11/dist/ttsc-dist/main.js/index.js:21118:15)
    at new BlobDownloadResponse (/home/runner/work/_actions/satackey/action-docker-layer-caching/v0.0.11/dist/ttsc-dist/main.js/index.js:21229:35)
    at BlockBlobClient.<anonymous> (/home/runner/work/_actions/satackey/action-docker-layer-caching/v0.0.11/dist/ttsc-dist/main.js/index.js:23389:47)
    at step (/home/runner/work/_actions/satackey/action-docker-layer-caching/v0.0.11/dist/ttsc-dist/main.js/index.js:32324:27)
    at Object.next (/home/runner/work/_actions/satackey/action-docker-layer-caching/v0.0.11/dist/ttsc-dist/main.js/index.js:32305:57)
    at fulfilled (/home/runner/work/_actions/satackey/action-docker-layer-caching/v0.0.11/dist/ttsc-dist/main.js/index.js:32295:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: TypeError: this.source.on is not a function
Warning: The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Warning: The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

結果就是GitHub Action每次執行Docker的時候都得要重新下載映像檔,拖慢了整個執行速度。

https://github.com/jpribyl/action-docker-layer-caching/issues/57

https://github.com/jpribyl/action-docker-layer-caching/issues/57

menhak提到該用「docker/build-push-action@v5」了。這似乎是個不錯的線索,但看起來好像是編譯Docker映像檔在用的?我的需求只有執行Docker映像檔而已,不會用到編譯呢。


大家有什麼好建議嗎?請在下面留言給我點提示吧QAQ