Skip to content

Commit 4a690fb

Browse files
authored
feat: support for 8.3 php images (#37)
1 parent 4d096fb commit 4a690fb

File tree

14 files changed

+530
-57
lines changed

14 files changed

+530
-57
lines changed

.dive-ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
rules:
2+
# If the efficiency is measured below X%, mark as failed.
3+
# Expressed as a ratio between 0-1.
4+
lowestEfficiency: 0.95
5+
6+
# If the amount of wasted space is at least X or larger than X, mark as failed.
7+
# Expressed in B, KB, MB, and GB.
8+
highestWastedBytes: 20MB
9+
10+
# If the amount of wasted space makes up for X% or more of the image, mark as failed.
11+
# Note: the base image layer is NOT included in the total image size.
12+
# Expressed as a ratio between 0-1; fails if the threshold is met or crossed.
13+
highestUserWastedPercent: 0.20

.github/workflows/build-latest.yml

Lines changed: 197 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,213 @@
11
---
22

3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
37
on: # yamllint disable-line rule:truthy
48
workflow_dispatch:
59
pull_request:
610
branches:
711
- master
812

13+
env:
14+
DOCKER_NAMESPACE: wayofdev/php-base
15+
GHCR_NAMESPACE: ghcr.io/wayofdev/docker-php-base
16+
917
name: 🚀 Build docker images with latest tag
1018

1119
jobs:
12-
# https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#example-returning-a-json-object
13-
prepare:
14-
runs-on: "ubuntu-latest"
15-
outputs:
16-
matrix: ${{ steps.matrix.outputs.matrix }}
20+
build:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os_name: ["alpine"]
25+
php_version: ["8.1", "8.2"]
26+
php_type: ["fpm", "cli", "supervisord"]
27+
builder: [{arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "ubuntu-latest"}]
28+
runs-on: ${{ matrix.builder.os }}
1729
steps:
18-
- name: ⚙️ Generate matrix
19-
id: matrix
30+
31+
- name: 🌎 Set environment variables
2032
run: |
21-
echo 'matrix={
22-
"os_name": ["alpine"],
23-
"php_version": ["8.1", "8.2"],
24-
"php_type": ["fpm", "cli", "supervisord"]
25-
}' | tr -d '\n' >> $GITHUB_OUTPUT
33+
php_version="${{ matrix.php_version }}"
34+
tag="${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ matrix.builder.arch }}"
35+
php_version_slug="${php_version//./}"
36+
target="php-${php_version_slug}-${{ matrix.php_type }}-${{ matrix.os_name }}"
37+
echo "TARGET=${target}" >> $GITHUB_ENV
38+
echo "PLATFORM_CACHE_TAG=${tag}" >> $GITHUB_ENV
2639
27-
build:
28-
needs: prepare
29-
strategy:
30-
matrix: ${{ fromJson(needs.prepare.outputs.matrix )}}
31-
uses: wayofdev/gh-actions/.github/workflows/build-image.yml@master
32-
with:
33-
os: "ubuntu-latest"
34-
push-to-hub: true
35-
image-namespace: "wayofdev/php-base"
36-
image-template-path: "./dist/base"
37-
image-template: ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
38-
image-version: latest
39-
secrets:
40-
docker-username: ${{ secrets.DOCKER_USERNAME }}
41-
docker-password: ${{ secrets.DOCKER_TOKEN }}
40+
- name: 📦 Check out the codebase
41+
uses: actions/checkout@v4
42+
43+
- name: 🤖 Generate dist files
44+
run: ansible-playbook src/playbook.yml -l ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
45+
46+
- name: 💻 Set up Docker for MacOS
47+
if: ${{ matrix.builder.os == 'macos-latest' }}
48+
uses: docker-practice/actions-setup-docker@master
49+
50+
- name: 🖥️ Setup docker QEMU
51+
uses: docker/setup-qemu-action@v3
52+
53+
- name: 🛠️ Set up Docker Buildx
54+
uses: docker/setup-buildx-action@v3
55+
with:
56+
buildkitd-flags: "--debug"
57+
58+
- name: 🐳 Extract docker meta data
59+
id: meta
60+
uses: docker/metadata-action@v5
61+
with:
62+
images: |
63+
${{ env.DOCKER_NAMESPACE }}
64+
${{ env.GHCR_NAMESPACE }}
65+
tags: |
66+
type=raw,event=branch,value=latest
67+
type=ref,event=pr
68+
type=semver,pattern={{version}}
69+
type=semver,pattern={{major}}.{{minor}}
70+
flavor: |
71+
latest=false
72+
prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-
73+
74+
- name: ⚙️ Rename meta bake definition file
75+
run: |
76+
mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta-${{ env.PLATFORM_CACHE_TAG }}.json"
77+
cat "/tmp/bake-meta-${{ env.PLATFORM_CACHE_TAG }}.json"
78+
79+
- name: 📤 Upload meta bake definition
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: bake-meta-${{ env.PLATFORM_CACHE_TAG }}
83+
path: /tmp/bake-meta-*.json
84+
if-no-files-found: error
85+
retention-days: 1
86+
87+
- name: 🔑 Login to docker-hub
88+
uses: docker/login-action@v3
89+
with:
90+
username: ${{ secrets.DOCKER_USERNAME }}
91+
password: ${{ secrets.DOCKER_TOKEN }}
92+
93+
- name: 🔑 Login to GHCR
94+
uses: docker/login-action@v3
95+
with:
96+
registry: ghcr.io
97+
username: ${{ github.repository_owner }}
98+
password: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: 🚀 Bake image and push to docker-hub and GHCR
101+
id: bake
102+
uses: docker/bake-action@v4
103+
with:
104+
targets: ${{ env.TARGET }}
105+
files: |
106+
./docker-bake.hcl
107+
/tmp/bake-meta-${{ env.PLATFORM_CACHE_TAG }}.json
108+
set: |
109+
*.tags=
110+
*.platform=linux/${{ matrix.builder.arch }}
111+
*.cache-from=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
112+
*.cache-to=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
113+
*.output=type=image,"name=${{ env.DOCKER_NAMESPACE }},${{ env.GHCR_NAMESPACE }}",push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
114+
115+
- name: 🔍 Debug Bake Metadata Output
116+
run: |
117+
echo "${{ steps.bake.outputs.metadata }}"
118+
119+
- name: 🔍 Debug baked image
120+
run: |
121+
tag=$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta-${{ env.PLATFORM_CACHE_TAG }}.json)
122+
if [ -z "$tag" ]; then
123+
echo "Tag is empty, skipping inspect."
124+
else
125+
echo "Tag extracted: $tag"
126+
docker buildx imagetools inspect ${{ env.DOCKER_NAMESPACE }}:${tag}
127+
fi
128+
129+
- name: 📥 Export digest
130+
run: |
131+
mkdir -p /tmp/digests
132+
echo "Bake Metadata: ${{ steps.bake.outputs.metadata }}"
133+
digest=$(echo '${{ steps.bake.outputs.metadata }}' | jq -r '.["${{ env.TARGET }}"]["containerimage.digest"]')
134+
if [[ -z "$digest" || "$digest" == "null" ]]; then
135+
echo "Digest not found."
136+
exit 1
137+
fi
138+
echo "Digest: $digest"
139+
touch "/tmp/digests/${digest#sha256:}"
140+
141+
- name: 📤 Upload digest
142+
uses: actions/upload-artifact@v4
143+
with:
144+
name: digests-${{ env.PLATFORM_CACHE_TAG }}
145+
path: /tmp/digests/*
146+
if-no-files-found: error
147+
retention-days: 1
148+
149+
merge:
150+
needs: build
151+
runs-on: ubuntu-latest
152+
steps:
153+
154+
- name: 📥 Download meta bake definitions
155+
uses: actions/download-artifact@v4
156+
with:
157+
pattern: bake-meta-*
158+
path: /tmp
159+
160+
- name: 📥 Download meta bake definitions
161+
uses: actions/download-artifact@v4
162+
with:
163+
pattern: digests-*
164+
path: /tmp/digests/*
165+
166+
- name: Print all download artifact files
167+
run: |
168+
ls -la /tmp
169+
ls -la /tmp/digests
170+
171+
- name: 🔑 Login to docker-hub
172+
uses: docker/login-action@v3
173+
with:
174+
username: ${{ secrets.DOCKER_USERNAME }}
175+
password: ${{ secrets.DOCKER_TOKEN }}
176+
177+
- name: 🔑 Login to GHCR
178+
uses: docker/login-action@v3
179+
with:
180+
registry: ghcr.io
181+
username: ${{ github.repository_owner }}
182+
password: ${{ secrets.GITHUB_TOKEN }}
183+
184+
- name: 🖥️ Setup docker QEMU
185+
uses: docker/setup-qemu-action@v3
186+
187+
- name: 🛠️ Set up Docker Buildx
188+
uses: docker/setup-buildx-action@v3
189+
with:
190+
buildkitd-flags: "--debug"
191+
192+
- name: Create manifest list and push
193+
run: |
194+
# Aggregate all tags from the meta files
195+
TAGS=$(jq -r '.target."docker-metadata-action".tags[]' /tmp/meta/bake-meta-*.json | sort -u)
196+
197+
# Loop through each tag and create a manifest list
198+
for TAG in $TAGS; do
199+
FULL_TAGS=()
200+
for FILE in /tmp/meta/bake-meta-*.json; do
201+
if jq -e --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE > /dev/null; then
202+
# Extract the repository and digest for the current platform
203+
REPO=$(jq -r --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE | cut -d':' -f1)
204+
DIGEST=$(jq -r '.["'$REPO'"]["containerimage.digest"]' $FILE)
205+
FULL_TAGS+=("$REPO@$DIGEST")
206+
fi
207+
done
208+
209+
# Create and push the manifest list for the current tag
210+
docker buildx imagetools create "${FULL_TAGS[@]}" -t "$TAG"
211+
done
42212
43213
...

.github/workflows/build-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run: |
2121
echo 'matrix={
2222
"os_name": ["alpine"],
23-
"php_version": ["8.1", "8.2"],
23+
"php_version": ["8.1", "8.2", "8.3"],
2424
"php_type": ["fpm", "cli", "supervisord"]
2525
}' | tr -d '\n' >> $GITHUB_OUTPUT
2626

.github/workflows/test.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- master
11+
paths-ignore:
12+
- '**.md'
13+
pull_request:
14+
paths-ignore:
15+
- '**.md'
16+
17+
env:
18+
DOCKER_NAMESPACE: wayofdev/php-base
19+
GHCR_NAMESPACE: ghcr.io/wayofdev/docker-php-base
20+
21+
name: 🧪 Test Docker images
22+
23+
jobs:
24+
test:
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
os_name: ["alpine"]
29+
php_version: ["8.1", "8.2", "8.3"]
30+
php_type: ["fpm", "cli", "supervisord"]
31+
builder: [{arch: "amd64", os: "ubuntu-latest"}]
32+
runs-on: ${{ matrix.builder.os }}
33+
steps:
34+
35+
- name: 🌎 Set environment variables
36+
run: |
37+
php_version="${{ matrix.php_version }}"
38+
tag="${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ matrix.builder.arch }}"
39+
php_version_slug="${php_version//./}"
40+
target="php-${php_version_slug}-${{ matrix.php_type }}-${{ matrix.os_name }}"
41+
echo "TARGET=${target}" >> $GITHUB_ENV
42+
echo "PLATFORM_CACHE_TAG=${tag}" >> $GITHUB_ENV
43+
44+
- name: 📦 Check out the codebase
45+
uses: actions/checkout@v4
46+
47+
- name: 🛠️ Install goss and dgoss
48+
uses: e1himself/[email protected]
49+
with:
50+
version: v0.4.6
51+
52+
- name: 🤖 Generate dist files
53+
run: ansible-playbook src/playbook.yml -l ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
54+
55+
- name: 🖥️ Setup docker QEMU
56+
uses: docker/setup-qemu-action@v3
57+
58+
- name: 🛠️ Set up Docker Buildx
59+
uses: docker/setup-buildx-action@v3
60+
with:
61+
buildkitd-flags: "--debug"
62+
63+
- name: 🔑 Login to docker-hub
64+
uses: docker/login-action@v3
65+
with:
66+
username: ${{ secrets.DOCKER_USERNAME }}
67+
password: ${{ secrets.DOCKER_TOKEN }}
68+
69+
- name: 🔑 Login to GHCR
70+
uses: docker/login-action@v3
71+
with:
72+
registry: ghcr.io
73+
username: ${{ github.repository_owner }}
74+
password: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: 🐳 Extract docker meta data
77+
id: meta
78+
uses: docker/metadata-action@v5
79+
with:
80+
images: |
81+
${{ env.DOCKER_NAMESPACE }}
82+
${{ env.GHCR_NAMESPACE }}
83+
tags: |
84+
type=raw,event=branch,value=latest
85+
type=ref,event=pr
86+
type=semver,pattern={{version}}
87+
type=semver,pattern={{major}}.{{minor}}
88+
flavor: |
89+
latest=false
90+
prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-
91+
92+
- name: 🧪 Bake image for testing
93+
id: bake
94+
uses: docker/bake-action@v4
95+
with:
96+
targets: ${{ env.TARGET }}
97+
files: |
98+
./docker-bake.hcl
99+
${{ steps.meta.outputs.bake-file }}
100+
set: |
101+
*.tags=
102+
*.platform=linux/${{ matrix.builder.arch }}
103+
*.cache-from=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
104+
*.cache-to=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
105+
*.output=type=docker,"name=${{ env.DOCKER_NAMESPACE }},${{ env.GHCR_NAMESPACE }}",name-canonical=true,push=false
106+
107+
- name: 🧪 Test Docker image
108+
run: |
109+
export IMAGE_TEMPLATE=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
110+
export IMAGE_TAG=${{ env.DOCKER_NAMESPACE }}:latest
111+
make test

0 commit comments

Comments
 (0)