如何在github-action内部缓存docker-compose构建 [英] How to cache docker-compose build inside github-action

查看:179
本文介绍了如何在github-action内部缓存docker-compose构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以缓存docker-compose,使其不会一次又一次地生成?这是我的动作工作流程文件:

Is there any way to cache docker-compose so that it will not build again and again? here is my action workflow file:

name: Github Action
on:
  push:
    branches:
      - staging
jobs:
  test:
    runs-on: ubuntu-18.04

    steps:
      - uses: actions/checkout@v1

      - name: Bootstrap app on Ubuntu
        uses: actions/setup-node@v1
        with:
          node-version: '12'


      - name: Install global packages
        run: npm install -g yarn prisma


      - name: Install project deps
        if: steps.cache-yarn.outputs.cache-hit != 'true'
        run: yarn


      - name: Build docker-compose
        run: docker-compose -f docker-compose.test.prisma.yml up --build -d

我想缓存docker build步骤.我试过使用 if:steps.cache-docker.outputs.cache-hit!='true'然后只能构建,但不起作用.

I want to cache the docker build step. I have tried using if: steps.cache-docker.outputs.cache-hit != 'true' then only build but didn't work.

推荐答案

您所指的是"docker layer caching",而GitHub Actions还不支持它.

What you are referring to is called "docker layer caching", and it is not yet natively supported in GitHub Actions.

在多个地方对此进行了广泛的讨论,例如:

This is discussed extensively in several places, like:

如评论中所述,有一些第三方行为提供了此功能(例如),但是对于这样的核心和基本功能,对于任何GitHub本身未正式支持的内容,我都会保持谨慎.

As mentioned in the comments, there are some 3rd party actions that provide this functionality (like this one), but for such a core and fundamental feature, I would be cautious with anything that is not officially supported by GitHub itself.

这篇关于如何在github-action内部缓存docker-compose构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆