Skip to content

Simplify php containers #3

Simplify php containers

Simplify php containers #3

Workflow file for this run

on:

Check failure on line 1 in .github/workflows/build-image.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-image.yml

Invalid workflow file

(Line: 43, Col: 19): Unrecognized function: 'replace'. Located at position 9 within expression: replace(replace(inputs.image, '.', ''), '-', ''), (Line: 64, Col: 14): Unrecognized function: 'replace'. Located at position 9 within expression: replace(replace(inputs.image, '.', ''), '-', '')
workflow_call:
inputs:
image:
required: true
type: string
context:
required: true
type: string
dockerfile:
required: false
type: string
default: 'Dockerfile'
multiarch:
required: false
type: boolean
default: true
push:
required: false
type: boolean
default: false
jobs:
build-image:
name: Build ${{ inputs.image }} image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Log in to Docker Hub
if: ${{ inputs.push == true }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
if: ${{ inputs.push == true }}
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: totara/docker-dev-${{ replace(replace(inputs.image, '.', ''), '-', '') }} # Strip - and . from the image name
# Adds tags for 'x.x.x' release version
tags: type=semver,pattern={{version}}
- name: Set up QEMU (to support building for both amd64 and arm64)
if: ${{ inputs.multiarch == true }}
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
with:
platforms: ${{ inputs.multiarch == true && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
- name: Build and push images
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
context: ${{ inputs.context }}
file: ${{ inputs.context }}/${{ inputs.dockerfile }}
platforms: ${{ inputs.multiarch == true && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: ${{ inputs.push == true && 'type=registry' || format('type=tar,dest={0}/{1}.tar,platform-split=false', github.workspace, inputs.image) }}
- name: Test running the image
if: ${{ inputs.push == false }}
run: |
cd ${{ github.workspace }}
cat ${{ inputs.image }}.tar | docker import - totara/docker-dev-${{ replace(replace(inputs.image, '.', ''), '-', '') }}:latest
./bin/tup ${{ inputs.image }}
sleep 10
./bin/tlogs ${{ inputs.image }}
./bin/tstop ${{ inputs.image }}