【问题标题】:How to cache docker-compose build inside github-action如何在 github-action 中缓存 docker-compose build
【发布时间】:2020-08-12 22:22:56
【问题描述】:

有没有办法缓存 docker-compose 使其不会一次又一次地构建? 这是我的操作工作流文件:

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' then only build,但没有成功。

【问题讨论】:

    标签: github docker-compose github-actions docker-build building-github-actions


    【解决方案1】:

    你所说的叫做“docker layer缓存”,它还没有被GitHub Actions原生支持。

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

    正如 cmets 中提到的,有一些 3rd 方操作可以提供此功能(例如 this one),但是对于这样一个核心和基本功能,我会谨慎对待任何未经 GitHub 本身官方支持的内容。

    【讨论】:

    【解决方案2】:

    对于那些通过 Google 到达这里的人,现在“支持”。或者至少它正在工作:https://github.community/t/use-docker-layer-caching-with-docker-compose-build-not-just-docker/156049。 这个想法是使用 docker(及其缓存)构建图像,然后使用 docker compose 运行(启动)它们。

    【讨论】:

      猜你喜欢
      • 2023-03-02
      • 1970-01-01
      • 2021-01-01
      • 2018-11-16
      • 2017-01-09
      • 1970-01-01
      • 2021-10-29
      • 2019-07-22
      相关资源
      最近更新 更多