Skip to content

Commit 756cba0

Browse files
committed
feat: upgrade to al2023
1 parent de5833f commit 756cba0

43 files changed

Lines changed: 1120 additions & 2905 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-publish-dev-images.yml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ on:
44
push:
55
branches:
66
- main
7-
paths-ignore:
8-
- 'tests/**'
7+
paths:
8+
- 'runtime/**'
9+
- 'src/**'
10+
- '.github/workflows/build-publish-dev-images.yml'
911

10-
# Required for Depot OIDC token authentication
1112
permissions:
1213
id-token: write
1314
contents: read
@@ -17,10 +18,15 @@ env:
1718

1819
jobs:
1920
publish:
20-
name: Build and publish development images
21+
name: Build and publish PHP ${{ matrix.php }} (${{ matrix.arch }})
2122
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
php: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"]
27+
arch: [x86_64, arm64]
28+
2229
steps:
23-
# See https://stackoverflow.com/questions/70312490/github-actions-runner-environment-doesnt-build-for-arm-images
2430
- name: Set up QEMU to run ARM images
2531
uses: docker/setup-qemu-action@v3
2632

@@ -31,10 +37,49 @@ jobs:
3137
uses: actions/checkout@v4
3238

3339
- name: Login to Docker Hub
34-
uses: docker/login-action@v2
40+
uses: docker/login-action@v3
3541
with:
3642
username: ${{ secrets.DOCKER_USERNAME }}
3743
password: ${{ secrets.DOCKER_PASSWORD }}
3844

39-
- name: Build and publish images
40-
run: make publish-dev-images
45+
- name: Determine Repository and Platform
46+
id: meta
47+
run: |
48+
if [ "${{ matrix.arch }}" = "x86_64" ]; then
49+
echo "repo=ymirapp/php-runtime-dev" >> $GITHUB_OUTPUT
50+
echo "platform=linux/amd64" >> $GITHUB_OUTPUT
51+
else
52+
echo "repo=ymirapp/arm-php-runtime-dev" >> $GITHUB_OUTPUT
53+
echo "platform=linux/arm64" >> $GITHUB_OUTPUT
54+
fi
55+
echo "tag=php-${{ matrix.php }}" >> $GITHUB_OUTPUT
56+
echo "dir=php-$(echo ${{ matrix.php }} | sed 's/\.//g')" >> $GITHUB_OUTPUT
57+
58+
- name: Build and Load Image
59+
uses: depot/build-push-action@v1
60+
with:
61+
project: ${{ secrets.DEPOT_PROJECT_ID }}
62+
context: runtime
63+
file: runtime/${{ steps.meta.outputs.dir }}/Dockerfile
64+
platforms: ${{ steps.meta.outputs.platform }}
65+
load: true
66+
tags: ${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag }}
67+
build-args: |
68+
CPU_ARCHITECTURE=${{ matrix.arch }}
69+
DOCKER_PLATFORM=${{ steps.meta.outputs.platform }}
70+
71+
- name: Verify Image
72+
run: ./runtime/test-image.sh ${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag }} ${{ steps.meta.outputs.platform }}
73+
74+
- name: Build and Push Image
75+
uses: depot/build-push-action@v1
76+
with:
77+
project: ${{ secrets.DEPOT_PROJECT_ID }}
78+
context: runtime
79+
file: runtime/${{ steps.meta.outputs.dir }}/Dockerfile
80+
platforms: ${{ steps.meta.outputs.platform }}
81+
push: true
82+
tags: ${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag }}
83+
build-args: |
84+
CPU_ARCHITECTURE=${{ matrix.arch }}
85+
DOCKER_PLATFORM=${{ steps.meta.outputs.platform }}

.github/workflows/build-publish-tag-images.yml

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
tags:
66
- '*'
77

8-
# Required for Depot OIDC token authentication
98
permissions:
109
id-token: write
1110
contents: read
@@ -14,11 +13,16 @@ env:
1413
DEPOT_PROJECT_ID: ${{ secrets.DEPOT_PROJECT_ID }}
1514

1615
jobs:
17-
publish:
18-
name: Build and publish images
16+
build-and-export:
17+
name: Build and export PHP ${{ matrix.php }} (${{ matrix.arch }})
1918
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
php: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"]
23+
arch: [x86_64, arm64]
24+
2025
steps:
21-
# See https://stackoverflow.com/questions/70312490/github-actions-runner-environment-doesnt-build-for-arm-images
2226
- name: Set up QEMU to run ARM images
2327
uses: docker/setup-qemu-action@v3
2428

@@ -29,18 +33,83 @@ jobs:
2933
uses: actions/checkout@v4
3034

3135
- name: Login to Docker Hub
32-
uses: docker/login-action@v2
36+
uses: docker/login-action@v3
3337
with:
3438
username: ${{ secrets.DOCKER_USERNAME }}
3539
password: ${{ secrets.DOCKER_PASSWORD }}
3640

37-
- name: Publish images
38-
run: make publish-images
41+
- name: Determine Platform and Directory
42+
id: meta
43+
run: |
44+
if [ "${{ matrix.arch }}" = "x86_64" ]; then
45+
echo "repo=ymirapp/php-runtime" >> $GITHUB_OUTPUT
46+
echo "platform=linux/amd64" >> $GITHUB_OUTPUT
47+
echo "archive_filename=php-${{ matrix.php }}" >> $GITHUB_OUTPUT
48+
else
49+
echo "repo=ymirapp/arm-php-runtime" >> $GITHUB_OUTPUT
50+
echo "platform=linux/arm64" >> $GITHUB_OUTPUT
51+
echo "archive_filename=arm-php-${{ matrix.php }}" >> $GITHUB_OUTPUT
52+
fi
53+
echo "tag=php-${{ matrix.php }}" >> $GITHUB_OUTPUT
54+
echo "dir=php-$(echo ${{ matrix.php }} | sed 's/\.//g')" >> $GITHUB_OUTPUT
3955
40-
- name: Build layers
41-
run: make build
56+
- name: Build and Load Image
57+
uses: depot/build-push-action@v1
58+
with:
59+
project: ${{ secrets.DEPOT_PROJECT_ID }}
60+
context: runtime
61+
file: runtime/${{ steps.meta.outputs.dir }}/Dockerfile
62+
platforms: ${{ steps.meta.outputs.platform }}
63+
load: true
64+
tags: ${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag }}
65+
build-args: |
66+
CPU_ARCHITECTURE=${{ matrix.arch }}
67+
DOCKER_PLATFORM=${{ steps.meta.outputs.platform }}
68+
69+
- name: Verify Image
70+
run: ./runtime/test-image.sh ${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag }} ${{ steps.meta.outputs.platform }}
71+
72+
- name: Build and Push Image
73+
uses: depot/build-push-action@v1
74+
with:
75+
project: ${{ secrets.DEPOT_PROJECT_ID }}
76+
context: runtime
77+
file: runtime/${{ steps.meta.outputs.dir }}/Dockerfile
78+
platforms: ${{ steps.meta.outputs.platform }}
79+
push: true
80+
tags: ${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag }}
81+
build-args: |
82+
CPU_ARCHITECTURE=${{ matrix.arch }}
83+
DOCKER_PLATFORM=${{ steps.meta.outputs.platform }}
84+
85+
- name: Export Layer ZIP
86+
run: |
87+
mkdir -p build
88+
docker run --rm --platform ${{ steps.meta.outputs.platform }} --entrypoint "/export.sh" \
89+
--env ARCHIVE_FILENAME=${{ steps.meta.outputs.archive_filename }} \
90+
--volume ${{ github.workspace }}:/ymir \
91+
--volume ${{ github.workspace }}/runtime/export.sh:/export.sh:ro \
92+
${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag }} .
93+
94+
- name: Upload Individual Layer
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: layer-${{ steps.meta.outputs.archive_filename }}
98+
path: build/${{ steps.meta.outputs.archive_filename }}.zip
99+
100+
collect-layers:
101+
name: Collect and Save Layers
102+
needs: build-and-export
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Download all layer artifacts
106+
uses: actions/download-artifact@v4
107+
with:
108+
path: build
109+
pattern: layer-*
110+
merge-multiple: true
42111

43-
- name: Upload layers
112+
- name: Upload final layers artifact
44113
uses: actions/upload-artifact@v4
45114
with:
46115
name: layers

runtime/Makefile

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,44 @@
11
SHELL := /bin/bash
2-
.PHONY: build build-images publish
2+
.PHONY: build publish publish-images publish-dev-images
33

4-
build: build-php-72.zip build-php-73.zip build-php-74.zip build-php-80.zip build-php-81.zip build-php-82.zip build-php-83.zip build-php-84.zip build-php-85.zip
4+
PHP_VERSIONS := 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5
55

6-
build-php%.zip: publish-images
7-
PHP_VERSION=$$(echo $@ | cut -d'.' -f 1 | cut -d'-' -f 2,3); \
8-
rm ${PWD}/../build/$$PHP_VERSION.zip; \
9-
rm ${PWD}/../build/arm-$$PHP_VERSION.zip; \
10-
docker run --rm --platform linux/amd64 --entrypoint "/export.sh" --env ARCHIVE_FILENAME=$$PHP_VERSION --volume ${PWD}/../:/ymir --volume ${PWD}/export.sh:/export.sh:ro ymirapp/php-runtime:$$PHP_VERSION .; \
11-
docker run --rm --platform linux/arm64 --entrypoint "/export.sh" --env ARCHIVE_FILENAME=arm-$$PHP_VERSION --volume ${PWD}/../:/ymir --volume ${PWD}/export.sh:/export.sh:ro ymirapp/arm-php-runtime:$$PHP_VERSION .
6+
build: $(addprefix build-php-, $(PHP_VERSIONS))
7+
8+
build-php-%:
9+
$(eval PHP_VER := $*)
10+
$(eval PHP_DIR := php-$(shell echo $* | sed 's/\.//g'))
11+
@echo "Building PHP $(PHP_VER)..."
12+
rm -f ${PWD}/../build/$(PHP_VER).zip
13+
rm -f ${PWD}/../build/arm-$(PHP_VER).zip
14+
# Build x86_64
15+
depot build -t ymirapp/php-runtime:php-$(PHP_VER) -f $(PHP_DIR)/Dockerfile . --load --build-arg CPU_ARCHITECTURE=x86_64 --build-arg DOCKER_PLATFORM=linux/amd64
16+
docker run --rm --platform linux/amd64 --entrypoint "/export.sh" --env ARCHIVE_FILENAME=$(PHP_VER) --volume ${PWD}/../:/ymir --volume ${PWD}/export.sh:/export.sh:ro ymirapp/php-runtime:php-$(PHP_VER) .
17+
# Build arm64
18+
depot build -t ymirapp/arm-php-runtime:php-$(PHP_VER) -f $(PHP_DIR)/Dockerfile . --load --build-arg CPU_ARCHITECTURE=arm64 --build-arg DOCKER_PLATFORM=linux/arm64
19+
docker run --rm --platform linux/arm64 --entrypoint "/export.sh" --env ARCHIVE_FILENAME=arm-$(PHP_VER) --volume ${PWD}/../:/ymir --volume ${PWD}/export.sh:/export.sh:ro ymirapp/arm-php-runtime:php-$(PHP_VER) .
1220

1321
publish-images-%:
14-
CPU_ARCHITECTURE=$$(echo '$*' | cut -d '-' -f 2); \
15-
DOCKER_PLATFORM=$$(echo '$*' | cut -d '-' -f 1 | sed 's/_/\//'); \
16-
if [ "$$CPU_ARCHITECTURE" = "x86_64" ]; then \
17-
RUNTIME_REPO="ymirapp/php-runtime"; \
18-
else \
19-
RUNTIME_REPO="ymirapp/arm-php-runtime"; \
20-
fi; \
21-
cd base ; depot build -t ymirapp/base:$$CPU_ARCHITECTURE . --push --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
22-
cd ../php-72 ; depot build -t $$RUNTIME_REPO:php-72 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
23-
cd ../php-73 ; depot build -t $$RUNTIME_REPO:php-73 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
24-
cd ../php-74 ; depot build -t $$RUNTIME_REPO:php-74 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
25-
cd ../php-80 ; depot build -t $$RUNTIME_REPO:php-80 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
26-
cd ../php-81 ; depot build -t $$RUNTIME_REPO:php-81 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
27-
cd ../php-82 ; depot build -t $$RUNTIME_REPO:php-82 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
28-
cd ../php-83 ; depot build -t $$RUNTIME_REPO:php-83 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
29-
cd ../php-84 ; depot build -t $$RUNTIME_REPO:php-84 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
30-
cd ../php-85 ; depot build -t $$RUNTIME_REPO:php-85 . --load --push --build-arg BASE_IMAGE=base --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE
22+
$(eval CPU_ARCHITECTURE := $(shell echo '$*' | cut -d '-' -f 2))
23+
$(eval DOCKER_PLATFORM := $(shell echo '$*' | cut -d '-' -f 1 | sed 's/_/\//'))
24+
$(eval RUNTIME_REPO := $(if $(filter x86_64,$(CPU_ARCHITECTURE)),ymirapp/php-runtime,ymirapp/arm-php-runtime))
25+
@for ver in $(PHP_VERSIONS); do \
26+
PHP_DIR=php-$$(echo $$ver | sed 's/\.//g'); \
27+
echo "Publishing PHP $$ver for $(CPU_ARCHITECTURE)..."; \
28+
depot build -t $(RUNTIME_REPO):php-$$ver -f $$PHP_DIR/Dockerfile . --push --platform=$(DOCKER_PLATFORM) --build-arg DOCKER_PLATFORM=$(DOCKER_PLATFORM) --build-arg CPU_ARCHITECTURE=$(CPU_ARCHITECTURE); \
29+
done
3130

3231
publish-images: publish-images-linux_amd64-x86_64 publish-images-linux_arm64-arm64
3332

3433
publish-dev-images-%:
35-
CPU_ARCHITECTURE=$$(echo '$*' | cut -d '-' -f 2); \
36-
DOCKER_PLATFORM=$$(echo '$*' | cut -d '-' -f 1 | sed 's/_/\//'); \
37-
if [ "$$CPU_ARCHITECTURE" = "x86_64" ]; then \
38-
RUNTIME_REPO="ymirapp/php-runtime-dev"; \
39-
else \
40-
RUNTIME_REPO="ymirapp/arm-php-runtime-dev"; \
41-
fi; \
42-
cd base ; depot build -t ymirapp/base-dev:$$CPU_ARCHITECTURE . --push --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
43-
cd ../php-72 ; depot build -t $$RUNTIME_REPO:php-72 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
44-
cd ../php-73 ; depot build -t $$RUNTIME_REPO:php-73 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
45-
cd ../php-74 ; depot build -t $$RUNTIME_REPO:php-74 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
46-
cd ../php-80 ; depot build -t $$RUNTIME_REPO:php-80 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
47-
cd ../php-81 ; depot build -t $$RUNTIME_REPO:php-81 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
48-
cd ../php-82 ; depot build -t $$RUNTIME_REPO:php-82 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
49-
cd ../php-83 ; depot build -t $$RUNTIME_REPO:php-83 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
50-
cd ../php-84 ; depot build -t $$RUNTIME_REPO:php-84 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE; \
51-
cd ../php-85 ; depot build -t $$RUNTIME_REPO:php-85 . --load --push --build-arg BASE_IMAGE=base-dev --platform=$$DOCKER_PLATFORM --build-arg DOCKER_PLATFORM=$$DOCKER_PLATFORM --build-arg CPU_ARCHITECTURE=$$CPU_ARCHITECTURE
34+
$(eval CPU_ARCHITECTURE := $(shell echo '$*' | cut -d '-' -f 2))
35+
$(eval DOCKER_PLATFORM := $(shell echo '$*' | cut -d '-' -f 1 | sed 's/_/\//'))
36+
$(eval RUNTIME_REPO := $(if $(filter x86_64,$(CPU_ARCHITECTURE)),ymirapp/php-runtime-dev,ymirapp/arm-php-runtime-dev))
37+
@for ver in $(PHP_VERSIONS); do \
38+
PHP_DIR=php-$$(echo $$ver | sed 's/\.//g'); \
39+
echo "Publishing Dev PHP $$ver for $(CPU_ARCHITECTURE)..."; \
40+
depot build -t $(RUNTIME_REPO):php-$$ver -f $$PHP_DIR/Dockerfile . --push --platform=$(DOCKER_PLATFORM) --build-arg DOCKER_PLATFORM=$(DOCKER_PLATFORM) --build-arg CPU_ARCHITECTURE=$(CPU_ARCHITECTURE); \
41+
done
5242

5343
publish-dev-images: publish-dev-images-linux_amd64-x86_64 publish-dev-images-linux_arm64-arm64
5444

0 commit comments

Comments
 (0)