ci: use bake file for container build
This commit is contained in:
parent
d6d1b83513
commit
0dd034b7b6
|
@ -1,31 +0,0 @@
|
|||
name: Build container
|
||||
description: Build and push a container
|
||||
|
||||
inputs:
|
||||
target:
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: docker/metadata-action@v4
|
||||
id: meta
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ inputs.target }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
|
||||
- uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
pull: true
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
build-args: |
|
||||
LIBRETIME_VERSION=${{ env.LIBRETIME_VERSION }}
|
||||
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
|
|
@ -11,12 +11,37 @@ concurrency:
|
|||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
meta:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
NAMESPACE: ${{ github.repository_owner }}
|
||||
strategy:
|
||||
matrix:
|
||||
target: [analyzer, api, legacy, playout, worker]
|
||||
|
||||
if: ${{ github.repository_owner == 'libretime' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: docker/metadata-action@v4
|
||||
id: meta
|
||||
with:
|
||||
bake-target: ${{ matrix.target }}
|
||||
images: |
|
||||
ghcr.io/libretime/libretime-${{ matrix.target }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
|
||||
- name: Upload metadata bake file
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: meta-${{ matrix.target }}
|
||||
path: ${{ steps.meta.outputs.bake-file }}
|
||||
|
||||
build:
|
||||
needs: [meta]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner == 'libretime' }}
|
||||
steps:
|
||||
|
@ -24,65 +49,35 @@ jobs:
|
|||
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
|
||||
- uses: docker/login-action@v2
|
||||
- name: Login ghcr.io
|
||||
if: github.event_name == 'push'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Download all metadata bake files
|
||||
uses: actions/download-artifact@v3
|
||||
|
||||
- name: Guess LIBRETIME_VERSION
|
||||
run: |
|
||||
make VERSION
|
||||
echo "LIBRETIME_VERSION=$(cat VERSION | tr -d [:blank:])" >> $GITHUB_ENV
|
||||
|
||||
- name: Build python-builder
|
||||
uses: docker/build-push-action@v4
|
||||
- name: Build
|
||||
uses: docker/bake-action@v2
|
||||
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@v4
|
||||
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@v4
|
||||
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
|
||||
|
||||
- name: Build api
|
||||
uses: ./.github/workflows/actions/build-container
|
||||
with:
|
||||
target: libretime-api
|
||||
|
||||
- name: Build playout
|
||||
uses: ./.github/workflows/actions/build-container
|
||||
with:
|
||||
target: libretime-playout
|
||||
|
||||
- name: Build worker
|
||||
uses: ./.github/workflows/actions/build-container
|
||||
with:
|
||||
target: libretime-worker
|
||||
|
||||
- name: Build legacy
|
||||
uses: ./.github/workflows/actions/build-container
|
||||
with:
|
||||
target: libretime-legacy
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
files: |
|
||||
docker-bake.json
|
||||
meta-analyzer/docker-metadata-action-bake.json
|
||||
meta-api/docker-metadata-action-bake.json
|
||||
meta-legacy/docker-metadata-action-bake.json
|
||||
meta-playout/docker-metadata-action-bake.json
|
||||
meta-worker/docker-metadata-action-bake.json
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=container
|
||||
*.cache-to=type=gha,scope=container,mode=max
|
||||
*.args.LIBRETIME_VERSION=${{ env.LIBRETIME_VERSION }}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"group": {
|
||||
"default": {
|
||||
"targets": ["analyzer", "playout", "api", "worker", "legacy"]
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"analyzer": {
|
||||
"target": "libretime-analyzer"
|
||||
},
|
||||
"playout": {
|
||||
"target": "libretime-playout"
|
||||
},
|
||||
"api": {
|
||||
"target": "libretime-api"
|
||||
},
|
||||
"worker": {
|
||||
"target": "libretime-worker"
|
||||
},
|
||||
"legacy": {
|
||||
"target": "libretime-legacy"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue