-
Notifications
You must be signed in to change notification settings - Fork 2
331 lines (327 loc) · 13.9 KB
/
create-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
name: Create images
on:
push:
paths:
- .github/workflows/create-images.yml
- "docker/**"
pull_request:
paths:
- .github/workflows/create-images.yml
- "docker/**"
jobs:
inspect:
name: Inspect environment
runs-on: ubuntu-latest
outputs:
publish: ${{ steps.check-publish.outputs.result }}
steps:
- name: Check if we have to publish the docker images
id: check-publish
run: |
PUBLISH_IMAGES=no
if [ "$GITHUB_REPOSITORY" != 'php-imagine/docker-builder' ]; then
echo "This is not the production repository: docker images won't be published"
elif [ "$GITHUB_EVENT_NAME" != 'push' ]; then
echo "This is a '$GITHUB_EVENT_NAME' event, not a 'push' event: docker images won't be published"
elif [ "$GITHUB_REF" != 'refs/heads/main' ]; then
echo "This is a push to '$GITHUB_REF', not to 'refs/heads/main' docker images won't be published"
else
echo 'Docker images will be published'
PUBLISH_IMAGES=yes
fi
echo "result=$PUBLISH_IMAGES" >> $GITHUB_OUTPUT
build-base-images:
name: PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
needs:
- inspect
env:
# The version of git to be installed if the default one is too old - see https://github.com/git/git/releases
GIT_VERSION: 2.33.0
# The version of libaom to be installed - see https://aomedia.googlesource.com/aom/+refs
LIBAOM_VERSION: 3.1.2
# The version of libdav1d to be installed - see https://code.videolan.org/videolan/dav1d/-/tags
LIBDAV1D_VERSION: 0.9.2
# The version of libavif to be installed - see https://github.com/AOMediaCodec/libavif/tags
LIBAVIF_VERSION: 0.9.2
# The version of libde265 to be installed - see https://github.com/strukturag/libde265/releases
LIBDE265_VERSION: 1.0.8
# The version of libheif to be installed - see # https://github.com/strukturag/libheif/releases
LIBHEIF_VERSION: 1.12.0
strategy:
fail-fast: false
matrix:
php-version:
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Create initial image
run: |
PHP_VERSION_DOCKERSUFFIX=''
if [ "${{ matrix.php-version }}" = '8.5' ]; then
PHP_VERSION_DOCKERSUFFIX='-rc'
fi
docker build \
--build-arg "PHP_VERSION=${{ matrix.php-version }}" \
--build-arg "PHP_VERSION_DOCKERSUFFIX=$PHP_VERSION_DOCKERSUFFIX" \
--tag "ghcr.io/php-imagine/test:${{ matrix.php-version }}-temp" \
--force-rm --rm \
--file ./docker/Dockerfile.base \
./docker
-
name: Create container
run: docker create -t --name imagine-${{ matrix.php-version }} "ghcr.io/php-imagine/test:${{ matrix.php-version }}-temp" bash
-
name: Start container
run: docker start imagine-${{ matrix.php-version }}
-
name: Temp
run: docker exec -t imagine-${{ matrix.php-version }} ls -al /usr/local/bin/
-
name: Fix apt
run: docker exec -t imagine-${{ matrix.php-version }} imagine-fix-apt
-
name: Update apt cache
run: docker exec -t imagine-${{ matrix.php-version }} apt-get update -q
-
name: Update apt packages
run: docker exec -t imagine-${{ matrix.php-version }} apt-get upgrade -qy
-
name: Fix Let's Encrypt CA certificate
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.php-version }} install-php-extensions @fix_letsencrypt
-
name: Inspect container environment
id: inspect
run: |
if docker exec -t imagine-${{ matrix.php-version }} imagine-install support-avif; then
echo 'AVIF is supported'
AVIF_SUPPORT=yes
else
AVIF_SUPPORT=no
fi
if docker exec -t imagine-${{ matrix.php-version }} imagine-install support-heic; then
echo 'HEIC is supported'
HEIC_SUPPORT=yes
else
HEIC_SUPPORT=no
fi
echo "avif-support=$AVIF_SUPPORT" >> $GITHUB_OUTPUT
echo "heic-support=$HEIC_SUPPORT" >> $GITHUB_OUTPUT
-
name: Install git
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install git $GIT_VERSION
-
name: Install libaom ${{ env.LIBAOM_VERSION }}
if: ${{ steps.inspect.outputs.avif-support == 'yes' || steps.inspect.outputs.heic-support == 'yes' }}
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libaom $LIBAOM_VERSION
-
name: Install libdav1d ${{ env.LIBDAV1D_VERSION }}
if: ${{ steps.inspect.outputs.avif-support == 'yes' }}
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libdav1d $LIBDAV1D_VERSION
-
name: Install libyuv
if: ${{ steps.inspect.outputs.avif-support == 'yes' || steps.inspect.outputs.heic-support == 'yes' }}
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libyuv
-
name: Install libavif ${{ env.LIBAVIF_VERSION }}
if: ${{ steps.inspect.outputs.avif-support == 'yes' }}
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libavif $LIBAVIF_VERSION
-
name: Install libde265 ${{ env.LIBDE265_VERSION }}
if: ${{ steps.inspect.outputs.heic-support == 'yes' }}
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libde265 $LIBDE265_VERSION
-
name: Install libheif ${{ env.LIBHEIF_VERSION }}
if: ${{ steps.inspect.outputs.heic-support == 'yes' }}
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install libheif $LIBHEIF_VERSION
-
name: Install Composer
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.php-version }} install-php-extensions @composer-2
-
name: Install xdebug PHP extension (without enabling it)
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 -e IPE_DONT_ENABLE=1 imagine-${{ matrix.php-version }} install-php-extensions xdebug
-
name: Install exif PHP extension
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.php-version }} install-php-extensions exif
-
name: Check exif PHP extension
run: docker exec -t imagine-${{ matrix.php-version }} php --ri exif
-
name: Cleanup
run: docker exec -t imagine-${{ matrix.php-version }} imagine-install cleanup
-
name: Check container
run: docker container ls -s --filter name=imagine-${{ matrix.php-version }}
-
name: Stop container
run: docker stop imagine-${{ matrix.php-version }}
-
name: Create base image
run: docker commit imagine-${{ matrix.php-version }} "ghcr.io/php-imagine/test:${{ matrix.php-version }}"
-
name: Save image
if: needs.inspect.outputs.publish == 'no'
run: docker save "ghcr.io/php-imagine/test:${{ matrix.php-version }}" | gzip >"/tmp/base-image-${{ matrix.php-version }}.tgz"
-
name: Upload image
if: needs.inspect.outputs.publish == 'no'
uses: actions/upload-artifact@v4
with:
name: base-image-${{ matrix.php-version }}
path: /tmp/base-image-${{ matrix.php-version }}.tgz
-
name: Login to the container registry
if: needs.inspect.outputs.publish == 'yes'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Upload image to the container registry
if: needs.inspect.outputs.publish == 'yes'
run: docker push "ghcr.io/php-imagine/test:${{ matrix.php-version }}"
build-final-images:
name: PHP ${{ matrix.config.php-version }} - ${{ matrix.extensions }}
runs-on: ubuntu-latest
needs:
- inspect
- build-base-images
strategy:
matrix:
config:
# GraphicsMagic versions: http://www.graphicsmagick.org/NEWS.html
# ImageMagick versions: https://www.imagemagick.org/download/releases
- php-version: "5.5"
graphicsmagic-version: "1.3.23"
imagemagick-version: "6.8.9-10"
- php-version: "5.6"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
- php-version: "7.0"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
- php-version: "7.1"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
- php-version: "7.2"
graphicsmagic-version: "1.3.36"
imagemagick-version: "6.8.9-10"
- php-version: "7.3"
graphicsmagic-version: "1.3.23"
imagemagick-version: "7.1.0-8"
- php-version: "7.4"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
- php-version: "8.0"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
- php-version: "8.1"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
- php-version: "8.2"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
- php-version: "8.3"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
- php-version: "8.4"
graphicsmagic-version: "1.3.36"
imagemagick-version: "7.1.0-8"
extensions:
- "gd-gmagick"
- "gd-imagick"
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Download base image
if: needs.inspect.outputs.publish == 'no'
uses: actions/download-artifact@v4
with:
name: base-image-${{ matrix.config.php-version }}
path: /tmp/
-
name: Load base image
if: needs.inspect.outputs.publish == 'no'
run: docker load --input /tmp/base-image-${{ matrix.config.php-version }}.tgz
-
name: Create container
run: docker create -t --name imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} "ghcr.io/php-imagine/test:${{ matrix.config.php-version }}" bash
-
name: Start container
run: docker start imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }}
-
name: Update apt cache
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} apt-get update -q
-
name: Install GraphicsMagic
if: ${{ contains(format('-{0}-', matrix.extensions), '-gmagick-') }}
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} imagine-install graphicsmagick ${{ matrix.config.graphicsmagic-version }}
-
name: Install gmagick PHP extension
if: ${{ contains(format('-{0}-', matrix.extensions), '-gmagick-') }}
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} install-php-extensions gmagick
-
name: Check gmagick PHP extension
if: ${{ contains(format('-{0}-', matrix.extensions), '-gmagick-') }}
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} php --ri gmagick
-
name: Install ImageMagick
if: ${{ contains(format('-{0}-', matrix.extensions), '-imagick-') }}
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} imagine-install imagemagick ${{ matrix.config.imagemagick-version }}
-
name: Install imagick PHP extension
if: ${{ contains(format('-{0}-', matrix.extensions), '-imagick-') }}
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} install-php-extensions imagick
-
name: Check imagick PHP extension
if: ${{ contains(format('-{0}-', matrix.extensions), '-imagick-') }}
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} php --ri imagick
-
name: Install gd PHP extension
if: ${{ contains(format('-{0}-', matrix.extensions), '-gd-') }}
run: docker exec -t -e IPE_KEEP_SYSPKG_CACHE=1 imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} install-php-extensions gd
-
name: Check gd PHP extension
if: ${{ contains(format('-{0}-', matrix.extensions), '-gd-') }}
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} php --ri gd
-
name: Cleanup
run: docker exec -t imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} imagine-install cleanup
-
name: Check container
run: docker container ls -s --filter name=imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }}
-
name: Stop container
run: docker stop imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }}
-
name: Create image
run: docker commit imagine-${{ matrix.config.php-version }}-${{ matrix.extensions }} "ghcr.io/php-imagine/test:${{ matrix.config.php-version }}-${{ matrix.extensions }}"
-
name: Login to the container registry
if: needs.inspect.outputs.publish == 'yes'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Upload image to the container registry
if: needs.inspect.outputs.publish == 'yes'
run: docker push "ghcr.io/php-imagine/test:${{ matrix.config.php-version }}-${{ matrix.extensions }}"