Skip to content

Commit 96150c5

Browse files
committed
Merge branch 'v3' into al2023
# Conflicts: # php-83/Dockerfile
2 parents 114315f + 57c642d commit 96150c5

File tree

11 files changed

+115
-81
lines changed

11 files changed

+115
-81
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ upload-to-docker-hub-php-%:
6767
for image in \
6868
"bref/${CPU_PREFIX}php-$*" "bref/${CPU_PREFIX}build-php-$*" "bref/${CPU_PREFIX}php-$*-dev"; \
6969
do \
70-
docker tag $$image $$image:2 ; \
70+
docker tag $$image $$image:3 ; \
7171
docker tag $$image $$image:${DOCKER_TAG} ; \
72-
docker push $$image --all-tags ; \
72+
docker push $$image:3 ; \
73+
docker push $$image:${DOCKER_TAG} ; \
7374
done
7475

7576

php-82/Dockerfile

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ RUN set -xe; \
8585
WORKDIR ${ZLIB_BUILD_DIR}/
8686
RUN set -xe; \
8787
make distclean \
88-
&& CFLAGS="" \
89-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
88+
&& CFLAGS="-Os" \
89+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
9090
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
9191
./configure \
9292
--prefix=${INSTALL_DIR}
@@ -113,8 +113,8 @@ RUN set -xe; \
113113
curl -Ls https://github.com/openssl/openssl/releases/download/openssl-${VERSION_OPENSSL}/openssl-${VERSION_OPENSSL}.tar.gz \
114114
| tar xzC ${OPENSSL_BUILD_DIR} --strip-components=1
115115
WORKDIR ${OPENSSL_BUILD_DIR}/
116-
RUN CFLAGS="" \
117-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
116+
RUN CFLAGS="-Os" \
117+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
118118
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
119119
./config \
120120
--prefix=${INSTALL_DIR} \
@@ -148,8 +148,8 @@ RUN set -xe; \
148148
curl -Ls https://download.gnome.org/sources/libxml2/${VERSION_XML2%.*}/libxml2-${VERSION_XML2}.tar.xz \
149149
| tar xJC ${XML2_BUILD_DIR} --strip-components=1
150150
WORKDIR ${XML2_BUILD_DIR}/
151-
RUN CFLAGS="" \
152-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
151+
RUN CFLAGS="-Os" \
152+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
153153
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
154154
./configure \
155155
--prefix=${INSTALL_DIR} \
@@ -181,8 +181,8 @@ RUN set -xe; \
181181
curl -Ls https://github.com/libssh2/libssh2/releases/download/libssh2-${VERSION_LIBSSH2}/libssh2-${VERSION_LIBSSH2}.tar.gz \
182182
| tar xzC ${LIBSSH2_BUILD_DIR} --strip-components=1
183183
WORKDIR ${LIBSSH2_BUILD_DIR}/bin/
184-
RUN CFLAGS="" \
185-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
184+
RUN CFLAGS="-Os" \
185+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
186186
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
187187
cmake .. \
188188
# Build as a shared library (.so) instead of a static one
@@ -214,8 +214,8 @@ RUN set -xe; \
214214
curl -Ls https://github.com/nghttp2/nghttp2/releases/download/v${VERSION_NGHTTP2}/nghttp2-${VERSION_NGHTTP2}.tar.gz \
215215
| tar xzC ${NGHTTP2_BUILD_DIR} --strip-components=1
216216
WORKDIR ${NGHTTP2_BUILD_DIR}/
217-
RUN CFLAGS="" \
218-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
217+
RUN CFLAGS="-Os" \
218+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
219219
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
220220
./configure \
221221
--enable-lib-only \
@@ -236,8 +236,8 @@ RUN set -xe; \
236236
curl -Ls https://github.com/rockdaboot/libpsl/releases/download/${VERSION_LIBPSL}/libpsl-${VERSION_LIBPSL}.tar.gz \
237237
| tar xzC ${LIBPSL_BUILD_DIR} --strip-components=1
238238
WORKDIR ${LIBPSL_BUILD_DIR}/
239-
RUN CFLAGS="" \
240-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
239+
RUN CFLAGS="-Os" \
240+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
241241
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
242242
./configure \
243243
--prefix=${INSTALL_DIR}
@@ -254,16 +254,16 @@ RUN make -j $(nproc) && make install
254254
# # - libnghttp2
255255
# # Needed by:
256256
# # - php
257-
ENV VERSION_CURL=8.12.1
257+
ENV VERSION_CURL=8.14.1
258258
ENV CURL_BUILD_DIR=${BUILD_DIR}/curl
259259
RUN set -xe; \
260260
mkdir -p ${CURL_BUILD_DIR}/bin; \
261261
curl -Ls https://github.com/curl/curl/archive/curl-${VERSION_CURL//./_}.tar.gz \
262262
| tar xzC ${CURL_BUILD_DIR} --strip-components=1
263263
WORKDIR ${CURL_BUILD_DIR}/
264264
RUN ./buildconf \
265-
&& CFLAGS="" \
266-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
265+
&& CFLAGS="-Os" \
266+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
267267
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
268268
./configure \
269269
--prefix=${INSTALL_DIR} \
@@ -294,15 +294,15 @@ RUN make install
294294
# https://github.com/nih-at/libzip/releases
295295
# Needed by:
296296
# - php
297-
ENV VERSION_ZIP=1.11.3
297+
ENV VERSION_ZIP=1.11.4
298298
ENV ZIP_BUILD_DIR=${BUILD_DIR}/zip
299299
RUN set -xe; \
300300
mkdir -p ${ZIP_BUILD_DIR}/bin/; \
301301
curl -Ls https://github.com/nih-at/libzip/releases/download/v${VERSION_ZIP}/libzip-${VERSION_ZIP}.tar.gz \
302302
| tar xzC ${ZIP_BUILD_DIR} --strip-components=1
303303
WORKDIR ${ZIP_BUILD_DIR}/bin/
304-
RUN CFLAGS="" \
305-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
304+
RUN CFLAGS="-Os" \
305+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
306306
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
307307
cmake .. \
308308
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
@@ -322,8 +322,8 @@ RUN set -xe; \
322322
curl -Ls https://github.com/jedisct1/libsodium/archive/${VERSION_LIBSODIUM}-RELEASE.tar.gz \
323323
| tar xzC ${LIBSODIUM_BUILD_DIR} --strip-components=1
324324
WORKDIR ${LIBSODIUM_BUILD_DIR}/
325-
RUN CFLAGS="" \
326-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
325+
RUN CFLAGS="-Os" \
326+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
327327
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
328328
./autogen.sh \
329329
&& ./configure --prefix=${INSTALL_DIR}
@@ -344,8 +344,8 @@ RUN set -xe; \
344344
curl -Ls https://github.com/postgres/postgres/archive/REL_${VERSION_POSTGRES//./_}.tar.gz \
345345
| tar xzC ${POSTGRES_BUILD_DIR} --strip-components=1
346346
WORKDIR ${POSTGRES_BUILD_DIR}/
347-
RUN CFLAGS="" \
348-
CPPFLAGS="-I${INSTALL_DIR}/include -I/usr/include" \
347+
RUN CFLAGS="-Os" \
348+
CPPFLAGS="-Os -I${INSTALL_DIR}/include -I/usr/include" \
349349
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
350350
./configure --prefix=${INSTALL_DIR} --with-openssl --without-icu --without-readline
351351
RUN cd ${POSTGRES_BUILD_DIR}/src/interfaces/libpq && make && make install
@@ -370,7 +370,7 @@ RUN set -xe; \
370370
curl -Ls https://github.com/kkos/oniguruma/releases/download/v${VERSION_ONIG}/onig-${VERSION_ONIG}.tar.gz \
371371
| tar xzC ${ONIG_BUILD_DIR} --strip-components=1
372372
WORKDIR ${ONIG_BUILD_DIR}
373-
RUN ./configure --prefix=${INSTALL_DIR}
373+
RUN CFLAGS="-Os" CPPFLAGS="-Os" ./configure --prefix=${INSTALL_DIR}
374374
RUN make && make install
375375

376376

@@ -384,14 +384,14 @@ RUN make && make install
384384
# Needed by:
385385
# - php
386386
RUN LD_LIBRARY_PATH= yum install -y tcl
387-
ENV VERSION_SQLITE=3.49.2
387+
ENV VERSION_SQLITE=3.50.0
388388
ENV SQLITE_BUILD_DIR=${BUILD_DIR}/sqlite
389389
RUN set -xe; \
390390
mkdir -p ${SQLITE_BUILD_DIR}; \
391391
curl -Ls https://github.com/sqlite/sqlite/archive/refs/tags/version-${VERSION_SQLITE}.tar.gz \
392392
| tar xzC ${SQLITE_BUILD_DIR} --strip-components=1
393393
WORKDIR ${SQLITE_BUILD_DIR}
394-
RUN ./configure --prefix=${INSTALL_DIR}
394+
RUN CFLAGS="-Os" CPPFLAGS="-Os" ./configure --prefix=${INSTALL_DIR}
395395
RUN make && make install
396396

397397

@@ -439,8 +439,8 @@ RUN curl --location --silent --show-error --fail https://www.php.net/get/php-${V
439439
# --with-zlib and --with-zlib-dir: See https://stackoverflow.com/a/42978649/245552
440440
ARG PHP_COMPILATION_FLAGS
441441
RUN ./buildconf --force
442-
RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
443-
CPPFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
442+
RUN CFLAGS="-fstack-protector-strong -fpic -fpie -Os -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
443+
CPPFLAGS="-fstack-protector-strong -fpic -fpie -Os -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
444444
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib -Wl,-O1 -Wl,--strip-all -Wl,--hash-style=both -pie" \
445445
./configure \
446446
--prefix=${INSTALL_DIR} \
@@ -462,14 +462,17 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I
462462
--enable-ftp \
463463
--with-gettext \
464464
--enable-mbstring \
465-
--with-pdo-mysql=shared,mysqlnd \
465+
--with-pdo-mysql=mysqlnd \
466466
--with-mysqli \
467467
--enable-pcntl \
468468
--with-zip \
469469
--enable-bcmath \
470470
--with-pdo-pgsql=shared,${INSTALL_DIR} \
471+
# Separate .so extension so that it is not loaded by default
471472
--enable-intl=shared \
472-
--enable-soap \
473+
# Separate .so extension so that it is not loaded by default
474+
--enable-soap=shared \
475+
# Separate .so extension so that it is not loaded by default
473476
--with-xsl=${INSTALL_DIR} \
474477
--with-ffi \
475478
# necessary for `pecl` to work (to install PHP extensions)
@@ -526,6 +529,10 @@ RUN cp ${CA_BUNDLE} /bref-layer/bref/ssl/cert.pem
526529
# Copy the OpenSSL config
527530
RUN cp ${INSTALL_DIR}/bref/ssl/openssl.cnf /bref-layer/bref/ssl/openssl.cnf
528531

532+
# Run `strip` over all libraries and extensions to reduce their size
533+
RUN find /bref-layer/bref/extensions -type f -exec strip --strip-all {} +
534+
RUN find /bref-layer/lib -type f -exec strip --strip-all {} +
535+
529536

530537
# ----------------------------------------------------------------------------
531538
# Start from a clean image to copy only the files we need for the Lambda layer
@@ -537,10 +544,11 @@ COPY --link --from=build-environment /bref-layer /opt
537544
COPY --link src/php.ini /opt/bref/etc/php/conf.d/bref.ini
538545
COPY --link src/php-fpm.conf /opt/bref/etc/php-fpm.conf
539546

540-
COPY --link src/bootstrap.php /opt/bootstrap
547+
COPY --link src/bootstrap.sh /opt/bootstrap
541548
# Copy files to /var/runtime to support deploying as a Docker image
542-
COPY --link src/bootstrap.php /var/runtime/bootstrap
549+
COPY --link src/bootstrap.sh /var/runtime/bootstrap
543550
RUN chmod +x /opt/bootstrap && chmod +x /var/runtime/bootstrap
551+
COPY --link src/bootstrap.php /opt/bref/bootstrap.php
544552

545553

546554
# ----------------------------------------------------------------------------

php-83/Dockerfile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ARG IMAGE_VERSION_SUFFIX
55

66
# https://www.php.net/downloads
7-
ARG VERSION_PHP=8.3.21
7+
ARG VERSION_PHP=8.3.22
88

99

1010
# Lambda uses a custom AMI named Amazon Linux 2023
@@ -108,8 +108,8 @@ RUN curl --location --silent --show-error --fail https://www.php.net/get/php-${V
108108
# --with-zlib and --with-zlib-dir: See https://stackoverflow.com/a/42978649/245552
109109
ARG PHP_COMPILATION_FLAGS
110110
RUN ./buildconf --force
111-
RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
112-
CPPFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
111+
RUN CFLAGS="-fstack-protector-strong -fpic -fpie -Os -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
112+
CPPFLAGS="-fstack-protector-strong -fpic -fpie -Os -I${INSTALL_DIR}/include -I/usr/include -ffunction-sections -fdata-sections" \
113113
LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib -Wl,-O1 -Wl,--strip-all -Wl,--hash-style=both -pie" \
114114
./configure \
115115
--prefix=${INSTALL_DIR} \
@@ -131,15 +131,18 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I
131131
--enable-ftp \
132132
--with-gettext \
133133
--enable-mbstring \
134-
--with-pdo-mysql=shared,mysqlnd \
134+
--with-pdo-mysql=mysqlnd \
135135
--with-mysqli \
136136
--enable-pcntl \
137137
--with-zip \
138138
--enable-bcmath \
139139
--with-pdo-pgsql=shared \
140+
# Separate .so extension so that it is not loaded by default
140141
--enable-intl=shared \
141-
--enable-soap \
142-
--with-xsl \
142+
# Separate .so extension so that it is not loaded by default
143+
--enable-soap=shared \
144+
# Separate .so extension so that it is not loaded by default
145+
--with-xsl=${INSTALL_DIR} \
143146
--with-ffi \
144147
# necessary for `pecl` to work (to install PHP extensions)
145148
--with-pear \
@@ -191,6 +194,10 @@ RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bref/extensions/pdo_pgs
191194
# Create a symbolic link to the OpenSSL certificates file for BC purposes
192195
RUN ln -s /etc/ssl/cert.pem /bref-layer/bref/ssl/cert.pem
193196

197+
# Run `strip` over all libraries and extensions to reduce their size
198+
RUN find /bref-layer/bref/extensions -type f -exec strip --strip-all {} +
199+
RUN find /bref-layer/lib -type f -exec strip --strip-all {} +
200+
194201

195202
# ----------------------------------------------------------------------------
196203
# Start from a clean image to copy only the files we need for the Lambda layer
@@ -202,10 +209,11 @@ COPY --link --from=build-environment /bref-layer /opt
202209
COPY --link src/php.ini /opt/bref/etc/php/conf.d/bref.ini
203210
COPY --link src/php-fpm.conf /opt/bref/etc/php-fpm.conf
204211

205-
COPY --link src/bootstrap.php /opt/bootstrap
212+
COPY --link src/bootstrap.sh /opt/bootstrap
206213
# Copy files to /var/runtime to support deploying as a Docker image
207-
COPY --link src/bootstrap.php /var/runtime/bootstrap
214+
COPY --link src/bootstrap.sh /var/runtime/bootstrap
208215
RUN chmod +x /opt/bootstrap && chmod +x /var/runtime/bootstrap
216+
COPY --link src/bootstrap.php /opt/bref/bootstrap.php
209217

210218

211219
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)