Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for 8.3 php images #37

Merged
merged 46 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5285434
feat: support for 8.3 php images
lotyp Jan 29, 2024
48041dc
feat: workaround for imagick on php 8.3
lotyp Mar 30, 2024
8196e06
feat: remove imagick, rdkafka, soap, imap support
lotyp Mar 30, 2024
6d36e23
feat: remove ldap extension
lotyp Mar 30, 2024
0023bdb
fix: one image per job per platform
lotyp Mar 30, 2024
88d0db4
ci: changing how images are built
lotyp Mar 31, 2024
732f088
chore: trigger ci
lotyp Mar 31, 2024
35c543a
chore: trigger ci
lotyp Mar 31, 2024
6963d6d
chore: trigger ci
lotyp Mar 31, 2024
8ce29bf
chore: trigger ci
lotyp Mar 31, 2024
80ef659
feat: add docker-bake file with image definitions
lotyp Apr 1, 2024
7cbcf18
fix: allow to generate single item of inventory
lotyp Apr 1, 2024
cc92909
chore: fix platform
lotyp Apr 1, 2024
84cc6c5
ci: fixes in docker bake action
lotyp Apr 1, 2024
dfa8855
chore: fix variable names in ci
lotyp Apr 1, 2024
bf9e41a
chore: fixes in ci
lotyp Apr 1, 2024
9da2fe5
chore: fixes in ci
lotyp Apr 2, 2024
c38f57b
chore: fixes in ci
lotyp Apr 2, 2024
c7169fa
chore: fixes in ci
lotyp Apr 2, 2024
929535d
chore: fixes in ci
lotyp Apr 2, 2024
d9171b7
chore: extract tags using meta action
lotyp Apr 2, 2024
f127055
chore: use meta tags
lotyp Apr 2, 2024
cf06b86
chore: add image inspect
lotyp Apr 2, 2024
2495447
chore: add image inspect
lotyp Apr 2, 2024
2845dee
chore: add image inspect
lotyp Apr 2, 2024
3cdb15a
chore: fix variable naming in ci
lotyp Apr 2, 2024
400dc30
chore: fix variable naming in ci
lotyp Apr 2, 2024
e8fea4e
chore: fix variable naming in ci
lotyp Apr 2, 2024
3abc3a3
chore: fixes
lotyp Apr 2, 2024
75fd6ef
chore: fixes
lotyp Apr 2, 2024
442f96e
chore: fixes
lotyp Apr 2, 2024
d83e196
chore: fixes
lotyp Apr 2, 2024
310f223
chore: fixes
lotyp Apr 2, 2024
eea1f25
chore: fixes
lotyp Apr 2, 2024
dbe6106
chore: fixes
lotyp Apr 2, 2024
54d145f
ci: add testing
lotyp Apr 3, 2024
0a12cc2
ci: add testing
lotyp Apr 3, 2024
020a4fa
ci: remove if block
lotyp Apr 3, 2024
d9086b8
ci: setup dgoss action
lotyp Apr 3, 2024
a7738a0
ci: setup dgoss action
lotyp Apr 3, 2024
2e0314e
ci: load image for testing
lotyp Apr 3, 2024
0152215
ci: use bake also for testing
lotyp Apr 3, 2024
d1757c6
ci: fix testing image
lotyp Apr 3, 2024
cdbddfa
ci: split to testing and build
lotyp Apr 3, 2024
1dc7e92
fix: add dgoss wait for fpm builds
lotyp Apr 3, 2024
dbb6c26
ci: add dgoss wait opts
lotyp Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .dive-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rules:
# If the efficiency is measured below X%, mark as failed.
# Expressed as a ratio between 0-1.
lowestEfficiency: 0.95

# If the amount of wasted space is at least X or larger than X, mark as failed.
# Expressed in B, KB, MB, and GB.
highestWastedBytes: 20MB

# If the amount of wasted space makes up for X% or more of the image, mark as failed.
# Note: the base image layer is NOT included in the total image size.
# Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
highestUserWastedPercent: 0.20
224 changes: 197 additions & 27 deletions .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,213 @@
---

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on: # yamllint disable-line rule:truthy
workflow_dispatch:
pull_request:
branches:
- master

env:
DOCKER_NAMESPACE: wayofdev/php-base
GHCR_NAMESPACE: ghcr.io/wayofdev/docker-php-base

name: 🚀 Build docker images with latest tag

jobs:
# https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#example-returning-a-json-object
prepare:
runs-on: "ubuntu-latest"
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
build:
strategy:
fail-fast: false
matrix:
os_name: ["alpine"]
php_version: ["8.1", "8.2"]
php_type: ["fpm", "cli", "supervisord"]
builder: [{arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "ubuntu-latest"}]
runs-on: ${{ matrix.builder.os }}
steps:
- name: ⚙️ Generate matrix
id: matrix

- name: 🌎 Set environment variables
run: |
echo 'matrix={
"os_name": ["alpine"],
"php_version": ["8.1", "8.2"],
"php_type": ["fpm", "cli", "supervisord"]
}' | tr -d '\n' >> $GITHUB_OUTPUT
php_version="${{ matrix.php_version }}"
tag="${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ matrix.builder.arch }}"
php_version_slug="${php_version//./}"
target="php-${php_version_slug}-${{ matrix.php_type }}-${{ matrix.os_name }}"
echo "TARGET=${target}" >> $GITHUB_ENV
echo "PLATFORM_CACHE_TAG=${tag}" >> $GITHUB_ENV

build:
needs: prepare
strategy:
matrix: ${{ fromJson(needs.prepare.outputs.matrix )}}
uses: wayofdev/gh-actions/.github/workflows/build-image.yml@master
with:
os: "ubuntu-latest"
push-to-hub: true
image-namespace: "wayofdev/php-base"
image-template-path: "./dist/base"
image-template: ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
image-version: latest
secrets:
docker-username: ${{ secrets.DOCKER_USERNAME }}
docker-password: ${{ secrets.DOCKER_TOKEN }}
- name: 📦 Check out the codebase
uses: actions/checkout@v4

- name: 🤖 Generate dist files
run: ansible-playbook src/playbook.yml -l ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}

- name: 💻 Set up Docker for MacOS
if: ${{ matrix.builder.os == 'macos-latest' }}
uses: docker-practice/actions-setup-docker@master

- name: 🖥️ Setup docker QEMU
uses: docker/setup-qemu-action@v3

- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: "--debug"

- name: 🐳 Extract docker meta data
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKER_NAMESPACE }}
${{ env.GHCR_NAMESPACE }}
tags: |
type=raw,event=branch,value=latest
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=false
prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-

- name: ⚙️ Rename meta bake definition file
run: |
mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta-${{ env.PLATFORM_CACHE_TAG }}.json"
cat "/tmp/bake-meta-${{ env.PLATFORM_CACHE_TAG }}.json"

- name: 📤 Upload meta bake definition
uses: actions/upload-artifact@v4
with:
name: bake-meta-${{ env.PLATFORM_CACHE_TAG }}
path: /tmp/bake-meta-*.json
if-no-files-found: error
retention-days: 1

- name: 🔑 Login to docker-hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: 🔑 Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🚀 Bake image and push to docker-hub and GHCR
id: bake
uses: docker/bake-action@v4
with:
targets: ${{ env.TARGET }}
files: |
./docker-bake.hcl
/tmp/bake-meta-${{ env.PLATFORM_CACHE_TAG }}.json
set: |
*.tags=
*.platform=linux/${{ matrix.builder.arch }}
*.cache-from=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
*.cache-to=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
*.output=type=image,"name=${{ env.DOCKER_NAMESPACE }},${{ env.GHCR_NAMESPACE }}",push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}

- name: 🔍 Debug Bake Metadata Output
run: |
echo "${{ steps.bake.outputs.metadata }}"

- name: 🔍 Debug baked image
run: |
tag=$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta-${{ env.PLATFORM_CACHE_TAG }}.json)
if [ -z "$tag" ]; then
echo "Tag is empty, skipping inspect."
else
echo "Tag extracted: $tag"
docker buildx imagetools inspect ${{ env.DOCKER_NAMESPACE }}:${tag}
fi

- name: 📥 Export digest
run: |
mkdir -p /tmp/digests
echo "Bake Metadata: ${{ steps.bake.outputs.metadata }}"
digest=$(echo '${{ steps.bake.outputs.metadata }}' | jq -r '.["${{ env.TARGET }}"]["containerimage.digest"]')
if [[ -z "$digest" || "$digest" == "null" ]]; then
echo "Digest not found."
exit 1
fi
echo "Digest: $digest"
touch "/tmp/digests/${digest#sha256:}"

- name: 📤 Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_CACHE_TAG }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
needs: build
runs-on: ubuntu-latest
steps:

- name: 📥 Download meta bake definitions
uses: actions/download-artifact@v4
with:
pattern: bake-meta-*
path: /tmp

- name: 📥 Download meta bake definitions
uses: actions/download-artifact@v4
with:
pattern: digests-*
path: /tmp/digests/*

- name: Print all download artifact files
run: |
ls -la /tmp
ls -la /tmp/digests

- name: 🔑 Login to docker-hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: 🔑 Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🖥️ Setup docker QEMU
uses: docker/setup-qemu-action@v3

- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: "--debug"

- name: Create manifest list and push
run: |
# Aggregate all tags from the meta files
TAGS=$(jq -r '.target."docker-metadata-action".tags[]' /tmp/meta/bake-meta-*.json | sort -u)

# Loop through each tag and create a manifest list
for TAG in $TAGS; do
FULL_TAGS=()
for FILE in /tmp/meta/bake-meta-*.json; do
if jq -e --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE > /dev/null; then
# Extract the repository and digest for the current platform
REPO=$(jq -r --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE | cut -d':' -f1)
DIGEST=$(jq -r '.["'$REPO'"]["containerimage.digest"]' $FILE)
FULL_TAGS+=("$REPO@$DIGEST")
fi
done

# Create and push the manifest list for the current tag
docker buildx imagetools create "${FULL_TAGS[@]}" -t "$TAG"
done

...
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: |
echo 'matrix={
"os_name": ["alpine"],
"php_version": ["8.1", "8.2"],
"php_version": ["8.1", "8.2", "8.3"],
"php_type": ["fpm", "cli", "supervisord"]
}' | tr -d '\n' >> $GITHUB_OUTPUT

Expand Down
111 changes: 111 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

env:
DOCKER_NAMESPACE: wayofdev/php-base
GHCR_NAMESPACE: ghcr.io/wayofdev/docker-php-base

name: 🧪 Test Docker images

jobs:
test:
strategy:
fail-fast: false
matrix:
os_name: ["alpine"]
php_version: ["8.1", "8.2", "8.3"]
php_type: ["fpm", "cli", "supervisord"]
builder: [{arch: "amd64", os: "ubuntu-latest"}]
runs-on: ${{ matrix.builder.os }}
steps:

- name: 🌎 Set environment variables
run: |
php_version="${{ matrix.php_version }}"
tag="${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ matrix.builder.arch }}"
php_version_slug="${php_version//./}"
target="php-${php_version_slug}-${{ matrix.php_type }}-${{ matrix.os_name }}"
echo "TARGET=${target}" >> $GITHUB_ENV
echo "PLATFORM_CACHE_TAG=${tag}" >> $GITHUB_ENV

- name: 📦 Check out the codebase
uses: actions/checkout@v4

- name: 🛠️ Install goss and dgoss
uses: e1himself/[email protected]
with:
version: v0.4.6

- name: 🤖 Generate dist files
run: ansible-playbook src/playbook.yml -l ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}

- name: 🖥️ Setup docker QEMU
uses: docker/setup-qemu-action@v3

- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: "--debug"

- name: 🔑 Login to docker-hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: 🔑 Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🐳 Extract docker meta data
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKER_NAMESPACE }}
${{ env.GHCR_NAMESPACE }}
tags: |
type=raw,event=branch,value=latest
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=false
prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-

- name: 🧪 Bake image for testing
id: bake
uses: docker/bake-action@v4
with:
targets: ${{ env.TARGET }}
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
set: |
*.tags=
*.platform=linux/${{ matrix.builder.arch }}
*.cache-from=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
*.cache-to=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
*.output=type=docker,"name=${{ env.DOCKER_NAMESPACE }},${{ env.GHCR_NAMESPACE }}",name-canonical=true,push=false

- name: 🧪 Test Docker image
run: |
export IMAGE_TEMPLATE=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
export IMAGE_TAG=${{ env.DOCKER_NAMESPACE }}:latest
make test
Loading