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

查看:39
本文介绍了如何在 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 构建步骤.我试过使用 if: steps.cache-docker.outputs.cache-hit != 'true' then only build 但没有用.

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:

正如评论中提到的,有一些 3rd 方操作提供了这个功能(比如 这个),但对于这样一个核心和基本功能,我会谨慎对待任何 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天全站免登陆