Skip to content

Container

Container #357

---
name: Container
on:
schedule:
# everyday at 10am
- cron: '0 10 * * *'
push:
branches:
- '**'
tags:
- 'v*.*.*'
pull_request:
env:
REGISTRY: quay.io
IMAGE_NAME: openshift-knative/showcase
NODE_VERSION: 16
jobs:
build-image:
name: Build Image
runs-on: ubuntu-22.04
strategy:
matrix:
app:
- quarkus
- expressjs
include:
- app: quarkus
kind: jvm
# FIXME: native is not working https://github.com/openshift-knative/showcase/issues/2
# - app: quarkus
# kind: native-standalone
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all branches and tags
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Prepare
id: prep
run: .github/workflows/prepare.sh
env:
KIND: ${{ matrix.kind }}
APP: ${{ matrix.app }}
- name: Build frontend
uses: redhat-actions/buildah-build@v2
with:
image: localhost/openshift-knative/frontend
tags: ${{ github.sha }}
containerfiles: frontend/deployment/Containerfile
platforms: ${{ steps.prep.outputs.platforms }}
build-args: CONTEXT_DIR=./frontend/
extra-args: --ulimit nofile=51200:51200
- name: Build the multi-arch image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
containerfiles: ${{ steps.prep.outputs.containerfile }}
tags: ${{ steps.prep.outputs.tags }} ${{ github.sha }}
platforms: ${{ steps.prep.outputs.platforms }}
build-args: |
CONTEXT_DIR=./${{ matrix.app }}/
APP_VERSION=${{ github.sha }}
extra-args: --ulimit nofile=51200:51200
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.kind=${{ matrix.kind }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
- name: Test the built container
run: |
set -Eeuxo pipefail
podman run --rm \
-d \
--name showcase \
-u 10001 \
-p 38080:8080 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
trap 'podman kill showcase' EXIT
curl --retry-all-errors --retry 8 -v -L --fail \
http://localhost:38080/
- name: Login to registry
uses: redhat-actions/podman-login@v1
if: ${{ steps.prep.outputs.push == 'true' }}
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Push to registry
if: ${{ steps.prep.outputs.push == 'true' }}
id: push-to-registry
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ env.REGISTRY }}
image: ${{ env.IMAGE_NAME }}
tags: ${{ steps.build-image.outputs.tags }}
- name: Print image url
if: ${{ steps.prep.outputs.push == 'true' }}
run: echo "Image pushed to ${{ steps.push-to-registry.outputs.registry-paths }}"