Skip to content

Commit b9293ee

Browse files
committed
Optimize layer sizes
The goal is to reduce layer sizes to optimize cold starts (that's the theory at least). - `strip` debug symbols for all libraries and PHP extensions (saves 11.7%) - compile PHP with the `-Os` C/CPP flag to optimize the binary for size (saves 8%) - compile libraries with the `-Os` flag (saves 6.3%) - disable the `soap` extension by default to avoid loading it on PHP startup (the only big unpopular extension I could find) - bundle the `pdo-mysql` extension in the PHP binary: it is extra small and will avoid loading it through an external file (small optimization) In total that's a 24% size reduction, i.e. 14.6MB. This is for Bref v3, I will run some benchmarks as just measuring the layer size doesn't tell us the full story about cold starts.
1 parent 71b4371 commit b9293ee

File tree

4 files changed

+99
-79
lines changed

4 files changed

+99
-79
lines changed

php-82/Dockerfile

Lines changed: 33 additions & 26 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}
@@ -262,8 +262,8 @@ RUN set -xe; \
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} \
@@ -301,8 +301,8 @@ RUN set -xe; \
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

@@ -391,7 +391,7 @@ RUN set -xe; \
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

php-83/Dockerfile

Lines changed: 33 additions & 26 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}
@@ -262,8 +262,8 @@ RUN set -xe; \
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} \
@@ -301,8 +301,8 @@ RUN set -xe; \
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

@@ -391,7 +391,7 @@ RUN set -xe; \
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

0 commit comments

Comments
 (0)