Skip to content

Docker Build

Docker Build #228

Workflow file for this run

# -----------------------------------------------------------------------------
# Copyright Helio Chissini de Castro 2022.
# Part of the SW360 Project.
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# -----------------------------------------------------------------------------
name: Docker Build
on:
schedule:
- cron: '0 0 * * *' # Midnight
workflow_dispatch:
branches:
- main
push:
tags:
- 'sw360-*'
paths-ignore:
- "**.md"
env:
REGISTRY: ghcr.io
permissions: write-all
jobs:
docker_push:
if: ${{ github.event.schedule }} == '0 0 * * *' || ${{ github.event.act }}
name: Build Docker Image
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout main repository
uses: actions/checkout@v3
- name: Set environment variables
run: |
cat .versions >> $GITHUB_ENV
echo "ORG_BASE_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
echo "GIT_REVISION=$(git describe --abbrev=6 --always --tags --match=[0-9]*)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
#------------------------------------------------
# Base
- name: Extract components metadata (tags, labels) for base image
id: meta_base
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/base
- name: Identify base image
run: echo "Will be tagged as ${{ steps.meta_base.outputs.tags }} and labeled as ${{ steps.meta_base.outputs.labels }}"
- name: Build sw360 base container
uses: docker/build-push-action@v4
with:
context: .
target: base
push: true
load: false
build-args: |
LIFERAY_VERSION=${{ env.LIFERAY_VERSION }}
LIFERAY_SOURCE=${{ env.LIFERAY_SOURCE }}
tags: |
${{ steps.meta_base.outputs.tags }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/base:${{ env.GIT_REVISION }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/base:latest
labels: ${{ steps.meta_base.outputs.labels }}
cache-from: type=gha,scope=base
cache-to: type=gha,scope=base,mode=max
#------------------------------------------------
# Thrift
- name: Extract components metadata (tags, labels) for thrift image
id: meta_thrift
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/thrift
- name: Identify thrift image
run: echo "Will be tagged as ${{ steps.meta_thrift.outputs.tags }} and labeled as ${{ steps.meta_thrift.outputs.labels }}"
- name: Build sw360 Thrift container
uses: docker/build-push-action@v4
with:
context: .
target: sw360thrift
push: true
load: false
build-args: |
THRIFT_VERSION=${{ env.THRIFT_VERSION }}
tags: |
${{ steps.meta_base.outputs.tags }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/thrift:${{ env.THRIFT_VERSION }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/thrift:latest
labels: ${{ steps.meta_thrift.outputs.labels }}
cache-from: type=gha,scope=thrift
cache-to: type=gha,scope=thrift,mode=max
#------------------------------------------------
# sw360 compilation
- name: Extract components metadata (tags, labels) for sw360
id: meta_sw360
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/binaries
- name: Identify sw360 build image
run: echo "Will be tagged as ${{ steps.meta_sw360.outputs.tags }} and labeled as ${{ steps.meta_sw360.outputs.labels }}"
- name: Build sw360 build container
uses: docker/build-push-action@v4
with:
context: .
target: sw360
push: true
load: false
secret-files: |
"sw360=./scripts/docker-config/default_secrets"
tags: |
${{ steps.meta_sw360.outputs.tags }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/binaries:${{ env.GIT_REVISION }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/binaries:latest
labels: ${{ steps.meta_sw360.outputs.labels }}
build-contexts: |
sw360thrift=docker-image://${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/thrift:latest
cache-from: type=gha,scope=sw360
cache-to: type=gha,scope=sw360,mode=max
#------------------------------------------------
# sw360 runtime container
- name: Extract components metadata (tags, labels) runtime image
id: meta_runtime
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}
- name: Identify sw360 runtime image
run: echo "Will be tagged as ${{ steps.meta_runtime.outputs.tags }} and labeled as ${{ steps.meta_runtime.outputs.labels }}"
- name: Build sw360 build container
uses: docker/build-push-action@v4
with:
context: .
target: runtime
push: true
load: false
tags: |
${{ steps.meta_runtime.outputs.tags }}
labels: ${{ steps.meta_runtime.outputs.labels }}
build-contexts: |
base=docker-image://${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/base:latest
sw360=docker-image://${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/binaries:latest
cache-from: type=gha,scope=runtime
cache-to: type=gha,scope=runtime,mode=max