Skip to content

Commit eb0fba2

Browse files
committed
Compress binaries with UPX
1 parent 6168124 commit eb0fba2

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

php-82/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ RUN set -xe; \
177177
cp php.ini-production ${INSTALL_DIR}/etc/php/php.ini
178178

179179

180+
# Compress the PHP binary and the PHP-FPM binary with UPX to reduce their size
181+
# --best: use the best compression method
182+
RUN set -xe; \
183+
export UPX_ARCH=$(test "${IMAGE_VERSION_SUFFIX}" = "x86_64" && echo amd64 || echo arm64); \
184+
curl -L -o upx.tgz https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-${UPX_ARCH}_linux.tar.xz; \
185+
tar xf upx.tgz; \
186+
mv upx-*/upx /usr/local/bin/
187+
RUN upx --best ${INSTALL_DIR}/bin/php && \
188+
upx --best ${INSTALL_DIR}/sbin/php-fpm
189+
190+
180191
# Install extensions
181192
# We can install extensions manually or using `pecl`
182193
RUN pecl install APCu

php-83/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ RUN set -xe; \
177177
cp php.ini-production ${INSTALL_DIR}/etc/php/php.ini
178178

179179

180+
# Compress the PHP binary and the PHP-FPM binary with UPX to reduce their size
181+
# --best: use the best compression method
182+
RUN set -xe; \
183+
export UPX_ARCH=$(test "${IMAGE_VERSION_SUFFIX}" = "x86_64" && echo amd64 || echo arm64); \
184+
curl -L -o upx.tgz https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-${UPX_ARCH}_linux.tar.xz; \
185+
tar xf upx.tgz; \
186+
mv upx-*/upx /usr/local/bin/
187+
RUN upx --best ${INSTALL_DIR}/bin/php && \
188+
upx --best ${INSTALL_DIR}/sbin/php-fpm
189+
190+
180191
# Install extensions
181192
# We can install extensions manually or using `pecl`
182193
RUN pecl install APCu

php-84/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ RUN set -xe; \
176176
cp php.ini-production ${INSTALL_DIR}/etc/php/php.ini
177177

178178

179+
# Compress the PHP binary and the PHP-FPM binary with UPX to reduce their size
180+
# --best: use the best compression method
181+
RUN set -xe; \
182+
export UPX_ARCH=$(test "${IMAGE_VERSION_SUFFIX}" = "x86_64" && echo amd64 || echo arm64); \
183+
curl -L -o upx.tgz https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-${UPX_ARCH}_linux.tar.xz; \
184+
tar xf upx.tgz; \
185+
mv upx-*/upx /usr/local/bin/
186+
RUN upx --best ${INSTALL_DIR}/bin/php && \
187+
upx --best ${INSTALL_DIR}/sbin/php-fpm
188+
189+
179190
# Install extensions
180191
# We can install extensions manually or using `pecl`
181192
RUN pecl install APCu

0 commit comments

Comments
 (0)