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

Multiarch images #323

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
context: .
platforms: ${{ matrix.platform }}
build-args: "php=${{ matrix.php }}"
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
org.opencontainers.image.title=PHP ${{ matrix.php }}
org.opencontainers.image.description=Docker image for PHP ${{ matrix.php }} FPM
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:
context: .
platforms: linux/amd64,linux/arm64
build-args: "php=${{ matrix.php }}"
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
org.opencontainers.image.title=PHP ${{ matrix.php }}
org.opencontainers.image.description=Docker image for PHP ${{ matrix.php }} FPM
Expand Down
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
ARG php="8.2"

## Base PHP images
FROM php:8.0-fpm-alpine@sha256:173daec831fa47844c876258a19741c7a1928524b5e1936a2b1e7c1f58ec1b12 AS php8.0
FROM php:8.1-fpm-alpine@sha256:a13add2aa7bdf1debe91ec56ba951823261295c907e00c2b6ffec69e842ba992 AS php8.1
FROM php:8.2-fpm-alpine@sha256:747e3f4843c75203c5e6aff70429368048cbeaa2a6e79b81f1a4e700b9e05add AS php8.2
FROM php:8.3-fpm-alpine@sha256:dc3e7bef05e4e8960d1138bd6da361a05a073e0bd40cd072144691d71ec5b834 AS php8.3
FROM php:8.0-fpm-alpine@sha256:bbf76d84a693fae1e0d2a259db70c9c47f41bd5a6ec3d339ba397939e7875dd8 AS php8.0
FROM php:8.1-fpm-alpine@sha256:d25c61d176d62c1929bd1d155fc4073b5d8d0db3f4a2d1ae67f580439409fc7f AS php8.1
FROM php:8.2-fpm-alpine@sha256:a16bc43404e602adb0f8f9662a1319f83d85daf23110bf7e02152a8a0e3d7e5e AS php8.2
FROM php:8.3-fpm-alpine@sha256:421373ae5f16b3afa03506de0ecbb4dcf39e4fe817b2a40b5f5c1f23c041dffa AS php8.3

## Helper images
FROM blackfire/blackfire:2@sha256:a701c54bdba874443b76ce27d2a6fbbe30e8ee517eb38823df4337b3461eef69 AS blackfire
FROM composer:2@sha256:79322ffd9050491d453fc403a17d23cfb898c353e06a88c9115d6f3b4239453d AS composer
FROM mlocati/php-extension-installer:2@sha256:ec28e7f57df76424cf3c46cc30ebcdbeb30e9305910828e6ba338fe16b9ab74b AS php-extension-installer

Check warning on line 12 in Dockerfile

View workflow job for this annotation

GitHub Actions / PHP (8.0, linux/arm64)

Base image platform does not match expected target platform

InvalidBaseImagePlatform: Base image mlocati/php-extension-installer:2@sha256:ec28e7f57df76424cf3c46cc30ebcdbeb30e9305910828e6ba338fe16b9ab74b was pulled with platform "linux/amd64", expected "linux/arm64" for current build

Check warning on line 12 in Dockerfile

View workflow job for this annotation

GitHub Actions / PHP (8.1, linux/arm64)

Base image platform does not match expected target platform

InvalidBaseImagePlatform: Base image mlocati/php-extension-installer:2@sha256:ec28e7f57df76424cf3c46cc30ebcdbeb30e9305910828e6ba338fe16b9ab74b was pulled with platform "linux/amd64", expected "linux/arm64" for current build

Check warning on line 12 in Dockerfile

View workflow job for this annotation

GitHub Actions / PHP (8.2, linux/arm64)

Base image platform does not match expected target platform

InvalidBaseImagePlatform: Base image mlocati/php-extension-installer:2@sha256:ec28e7f57df76424cf3c46cc30ebcdbeb30e9305910828e6ba338fe16b9ab74b was pulled with platform "linux/amd64", expected "linux/arm64" for current build

Check warning on line 12 in Dockerfile

View workflow job for this annotation

GitHub Actions / PHP (8.3, linux/arm64)

Base image platform does not match expected target platform

InvalidBaseImagePlatform: Base image mlocati/php-extension-installer:2@sha256:ec28e7f57df76424cf3c46cc30ebcdbeb30e9305910828e6ba338fe16b9ab74b was pulled with platform "linux/amd64", expected "linux/arm64" for current build

## Custom PHP image
# hadolint ignore=DL3006
Expand All @@ -23,8 +23,6 @@

COPY context/ /

COPY --from=blackfire /usr/local/bin/blackfire /usr/bin
COPY --from=composer /usr/bin/composer /usr/bin
COPY --from=php-extension-installer /usr/bin/install-php-extensions /usr/bin

RUN <<EOT
Expand All @@ -36,6 +34,9 @@
adduser -H -D -S -G wheel -u 1000 linuxhost
EOT

COPY --from=blackfire /usr/local/bin/blackfire /usr/bin
COPY --from=composer /usr/bin/composer /usr/bin

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
RUN curl https://endoflife.date/api/php/${php}.json| jq '{support,eol,lts}' > /etc/eol.json

Expand Down
3 changes: 2 additions & 1 deletion bin/update-php-images-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mapfile -t versions < <(grep -E '^FROM .* AS php[0-9\.]+$' Dockerfile | cut -f 4

for version in "${versions[@]}"; do
image=$(grep "AS ${version}" Dockerfile | cut -f 2 -d ' ' | cut -f 1 -d @)
new=$(docker buildx imagetools inspect --raw "${image}" | jq -r '.manifests[0].digest')
docker pull "${image}"
new=$(docker image inspect "${image}" | jq -r '.[0].RepoDigests[0]' | cut -f 2 -d @)
sed -i "s#FROM .*AS ${version}#FROM ${image}@${new} AS ${version}#" Dockerfile
done