ci: improve containers build caching

This commit is contained in:
jo 2022-09-14 20:31:19 +02:00 committed by Kyle Robbertze
parent 1c3c15f3af
commit 369b85018a
2 changed files with 40 additions and 14 deletions

View File

@ -4,8 +4,6 @@ description: Build and push a container
inputs:
target:
required: true
images:
required: true
runs:
using: composite
@ -13,12 +11,15 @@ runs:
- uses: docker/metadata-action@v4
id: meta
with:
images: ${{ inputs.images }}
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ inputs.target }}
- uses: docker/build-push-action@v3
with:
context: .
push: ${{ startsWith(github.ref, 'refs/tags') }}
pull: true
push: ${{ github.event_name == 'push' }}
target: ${{ inputs.target }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ inputs.target }}
cache-to: type=gha,scope=${{ inputs.target }},mode=max

View File

@ -17,43 +17,68 @@ jobs:
env:
REGISTRY: ghcr.io
NAMESPACE: ${{ github.repository_owner }}
CACHE_REF: ghcr.io/${{ github.repository_owner }}/libretime-cache
if: ${{ github.repository_owner == 'libretime' }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build libretime-analyzer
- name: Build python-builder
uses: docker/build-push-action@v3
with:
context: .
pull: true
target: python-builder
cache-from: type=gha,scope=python-builder
cache-to: type=gha,scope=python-builder,mode=max
- name: Build python-base
uses: docker/build-push-action@v3
with:
context: .
pull: true
target: python-base
cache-from: type=gha,scope=python-base
cache-to: type=gha,scope=python-base,mode=max
- name: Build python-base-ffmpeg
uses: docker/build-push-action@v3
with:
context: .
pull: true
target: python-base-ffmpeg
cache-from: type=gha,scope=python-base-ffmpeg
cache-to: type=gha,scope=python-base-ffmpeg,mode=max
- name: Build analyzer
uses: ./.github/workflows/actions/build-container
with:
target: libretime-analyzer
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/libretime-analyzer
- name: Build libretime-api
- name: Build api
uses: ./.github/workflows/actions/build-container
with:
target: libretime-api
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/libretime-api
- name: Build libretime-playout
- name: Build playout
uses: ./.github/workflows/actions/build-container
with:
target: libretime-playout
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/libretime-playout
- name: Build libretime-worker
- name: Build worker
uses: ./.github/workflows/actions/build-container
with:
target: libretime-worker
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/libretime-worker
- name: Build libretime-legacy
- name: Build legacy
uses: ./.github/workflows/actions/build-container
with:
target: libretime-legacy
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/libretime-legacy