Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de46261

Browse files
committed
feat(build) optimize base pipeline
1 parent 58ce09a commit de46261

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

.github/workflows/base-images.yml

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,52 @@ jobs:
4545
- name: Set up Docker Buildx
4646
uses: docker/setup-buildx-action@v3
4747

48+
# BUILD AMD64 IMAGE
49+
- name: Build PHP Base Image - amd64
50+
uses: docker/build-push-action@v6
51+
with:
52+
platforms: linux/amd64
53+
context: .
54+
file: flavors/vanilla/Dockerfile
55+
load: true
56+
cache-from: type=gha
57+
cache-to: type=gha,mode=max
58+
build-args: |
59+
PHP_VERSION=${{ matrix.php_version }}
60+
tags: |
61+
fbraz3/php-cli:${{ matrix.php_version }}-amd64
62+
63+
- name: Test images - amd64
64+
run: |
65+
docker run --rm --platform=linux/amd64 fbraz3/php-cli:${{ matrix.php_version }}-amd64 -v
66+
docker run --rm --platform=linux/amd64 fbraz3/php-cli:${{ matrix.php_version }}-amd64 -v | grep -q "${{ matrix.php_version }}" || exit 1
67+
env:
68+
PHP_VERSION: ${{ matrix.php_version }}
69+
70+
# BUILD ARM64 IMAGE
71+
- name: Build PHP Base Image - arm64
72+
uses: docker/build-push-action@v6
73+
with:
74+
platforms: linux/arm64
75+
context: .
76+
file: flavors/vanilla/Dockerfile
77+
load: true
78+
cache-from: type=gha
79+
cache-to: type=gha,mode=max
80+
build-args: |
81+
PHP_VERSION=${{ matrix.php_version }}
82+
tags: |
83+
fbraz3/php-cli:${{ matrix.php_version }}-arm64
84+
85+
- name: Test images - arm64
86+
run: |
87+
docker run --rm --platform=linux/arm64 fbraz3/php-cli:${{ matrix.php_version }}-arm64 -v
88+
docker run --rm --platform=linux/arm64 fbraz3/php-cli:${{ matrix.php_version }}-arm64 -v | grep -q "${{ matrix.php_version }}" || exit 1
89+
env:
90+
PHP_VERSION: ${{ matrix.php_version }}
91+
92+
# BUILD AND PUSH IMAGES TO BOTH ARCHITECTURES
93+
# Github Actions cache is used to speed up the build process and ensure that the tests are run on the latest image
4894
- name: Login to Docker Hub
4995
uses: docker/login-action@v3
5096
with:
@@ -67,12 +113,3 @@ jobs:
67113
fbraz3/php-base:${{ matrix.php_version }}
68114
${{ matrix.is_latest && 'fbraz3/php-cli:latest' || '' }}
69115
${{ matrix.is_latest && 'fbraz3/php-base:latest' || '' }}
70-
71-
- name: Test images
72-
run: |
73-
docker run --rm --platform=linux/amd64 fbraz3/php-cli:${{ matrix.php_version }} -v
74-
docker run --rm --platform=linux/arm64 fbraz3/php-cli:${{ matrix.php_version }} -v
75-
docker run --rm --platform=linux/amd64 fbraz3/php-cli:${{ matrix.php_version }} -v | grep -q "${{ matrix.php_version }}" || exit 1
76-
docker run --rm --platform=linux/arm64 fbraz3/php-cli:${{ matrix.php_version }} -v | grep -q "${{ matrix.php_version }}" || exit 1
77-
env:
78-
PHP_VERSION: ${{ matrix.php_version }}

0 commit comments

Comments
 (0)