Skip to content

Commit 796b04b

Browse files
committed
Strip debugging information to reduce file sizes
1 parent 92b217f commit 796b04b

14 files changed

Lines changed: 378 additions & 14 deletions

.ansible/DOCKERFILES/Dockerfile-slim.j2

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,32 @@ RUN set -eux \
163163
cp -r /usr/bin/mongo* /tmp/mongo/; \
164164
fi
165165

166+
###
167+
### Strip debugging information to smallen filesize
168+
###
169+
RUN set -eux \
170+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
171+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
172+
\
173+
&& for bin in ${STRIP_USR_BINS}; do \
174+
( \
175+
find /usr/bin/ -name "${bin}"* -type f -print0 \
176+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
177+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
178+
) \
179+
done \
180+
\
181+
&& for dir in ${STRIP_DIRS}; do \
182+
( \
183+
find ${dir} -type f -print0 \
184+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
185+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
186+
) \
187+
done \
188+
\
189+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
190+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
191+
166192

167193

168194
########################################################################################################################
@@ -180,7 +206,7 @@ FROM devilbox/php-fpm:{{ php_version }}-prod as devilbox-slim-base
180206
ARG ARCH
181207

182208
###
183-
### Copy shared libraries
209+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
184210
###
185211
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
186212
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

Dockerfiles/slim/Dockerfile-5.2

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,32 @@ RUN set -eux \
209209
cp -r /usr/bin/mongo* /tmp/mongo/; \
210210
fi
211211

212+
###
213+
### Strip debugging information to smallen filesize
214+
###
215+
RUN set -eux \
216+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
217+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
218+
\
219+
&& for bin in ${STRIP_USR_BINS}; do \
220+
( \
221+
find /usr/bin/ -name "${bin}"* -type f -print0 \
222+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
223+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
224+
) \
225+
done \
226+
\
227+
&& for dir in ${STRIP_DIRS}; do \
228+
( \
229+
find ${dir} -type f -print0 \
230+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
231+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
232+
) \
233+
done \
234+
\
235+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
236+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
237+
212238

213239

214240
########################################################################################################################
@@ -226,7 +252,7 @@ FROM devilbox/php-fpm:5.2-prod as devilbox-slim-base
226252
ARG ARCH
227253

228254
###
229-
### Copy shared libraries
255+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
230256
###
231257
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
232258
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

Dockerfiles/slim/Dockerfile-5.3

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,32 @@ RUN set -eux \
209209
cp -r /usr/bin/mongo* /tmp/mongo/; \
210210
fi
211211

212+
###
213+
### Strip debugging information to smallen filesize
214+
###
215+
RUN set -eux \
216+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
217+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
218+
\
219+
&& for bin in ${STRIP_USR_BINS}; do \
220+
( \
221+
find /usr/bin/ -name "${bin}"* -type f -print0 \
222+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
223+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
224+
) \
225+
done \
226+
\
227+
&& for dir in ${STRIP_DIRS}; do \
228+
( \
229+
find ${dir} -type f -print0 \
230+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
231+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
232+
) \
233+
done \
234+
\
235+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
236+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
237+
212238

213239

214240
########################################################################################################################
@@ -226,7 +252,7 @@ FROM devilbox/php-fpm:5.3-prod as devilbox-slim-base
226252
ARG ARCH
227253

228254
###
229-
### Copy shared libraries
255+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
230256
###
231257
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
232258
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

Dockerfiles/slim/Dockerfile-5.4

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,32 @@ RUN set -eux \
209209
cp -r /usr/bin/mongo* /tmp/mongo/; \
210210
fi
211211

212+
###
213+
### Strip debugging information to smallen filesize
214+
###
215+
RUN set -eux \
216+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
217+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
218+
\
219+
&& for bin in ${STRIP_USR_BINS}; do \
220+
( \
221+
find /usr/bin/ -name "${bin}"* -type f -print0 \
222+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
223+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
224+
) \
225+
done \
226+
\
227+
&& for dir in ${STRIP_DIRS}; do \
228+
( \
229+
find ${dir} -type f -print0 \
230+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
231+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
232+
) \
233+
done \
234+
\
235+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
236+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
237+
212238

213239

214240
########################################################################################################################
@@ -226,7 +252,7 @@ FROM devilbox/php-fpm:5.4-prod as devilbox-slim-base
226252
ARG ARCH
227253

228254
###
229-
### Copy shared libraries
255+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
230256
###
231257
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
232258
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

Dockerfiles/slim/Dockerfile-5.5

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,32 @@ RUN set -eux \
209209
cp -r /usr/bin/mongo* /tmp/mongo/; \
210210
fi
211211

212+
###
213+
### Strip debugging information to smallen filesize
214+
###
215+
RUN set -eux \
216+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
217+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
218+
\
219+
&& for bin in ${STRIP_USR_BINS}; do \
220+
( \
221+
find /usr/bin/ -name "${bin}"* -type f -print0 \
222+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
223+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
224+
) \
225+
done \
226+
\
227+
&& for dir in ${STRIP_DIRS}; do \
228+
( \
229+
find ${dir} -type f -print0 \
230+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
231+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
232+
) \
233+
done \
234+
\
235+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
236+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
237+
212238

213239

214240
########################################################################################################################
@@ -226,7 +252,7 @@ FROM devilbox/php-fpm:5.5-prod as devilbox-slim-base
226252
ARG ARCH
227253

228254
###
229-
### Copy shared libraries
255+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
230256
###
231257
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
232258
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

Dockerfiles/slim/Dockerfile-5.6

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,32 @@ RUN set -eux \
213213
cp -r /usr/bin/mongo* /tmp/mongo/; \
214214
fi
215215

216+
###
217+
### Strip debugging information to smallen filesize
218+
###
219+
RUN set -eux \
220+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
221+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
222+
\
223+
&& for bin in ${STRIP_USR_BINS}; do \
224+
( \
225+
find /usr/bin/ -name "${bin}"* -type f -print0 \
226+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
227+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
228+
) \
229+
done \
230+
\
231+
&& for dir in ${STRIP_DIRS}; do \
232+
( \
233+
find ${dir} -type f -print0 \
234+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
235+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
236+
) \
237+
done \
238+
\
239+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
240+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
241+
216242

217243

218244
########################################################################################################################
@@ -230,7 +256,7 @@ FROM devilbox/php-fpm:5.6-prod as devilbox-slim-base
230256
ARG ARCH
231257

232258
###
233-
### Copy shared libraries
259+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
234260
###
235261
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
236262
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

Dockerfiles/slim/Dockerfile-7.0

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,32 @@ RUN set -eux \
213213
cp -r /usr/bin/mongo* /tmp/mongo/; \
214214
fi
215215

216+
###
217+
### Strip debugging information to smallen filesize
218+
###
219+
RUN set -eux \
220+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
221+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
222+
\
223+
&& for bin in ${STRIP_USR_BINS}; do \
224+
( \
225+
find /usr/bin/ -name "${bin}"* -type f -print0 \
226+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
227+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
228+
) \
229+
done \
230+
\
231+
&& for dir in ${STRIP_DIRS}; do \
232+
( \
233+
find ${dir} -type f -print0 \
234+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
235+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
236+
) \
237+
done \
238+
\
239+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
240+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
241+
216242

217243

218244
########################################################################################################################
@@ -230,7 +256,7 @@ FROM devilbox/php-fpm:7.0-prod as devilbox-slim-base
230256
ARG ARCH
231257

232258
###
233-
### Copy shared libraries
259+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
234260
###
235261
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
236262
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

Dockerfiles/slim/Dockerfile-7.1

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,32 @@ RUN set -eux \
207207
cp -r /usr/bin/mongo* /tmp/mongo/; \
208208
fi
209209

210+
###
211+
### Strip debugging information to smallen filesize
212+
###
213+
RUN set -eux \
214+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
215+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
216+
\
217+
&& for bin in ${STRIP_USR_BINS}; do \
218+
( \
219+
find /usr/bin/ -name "${bin}"* -type f -print0 \
220+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
221+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
222+
) \
223+
done \
224+
\
225+
&& for dir in ${STRIP_DIRS}; do \
226+
( \
227+
find ${dir} -type f -print0 \
228+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
229+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
230+
) \
231+
done \
232+
\
233+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
234+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
235+
210236

211237

212238
########################################################################################################################
@@ -224,7 +250,7 @@ FROM devilbox/php-fpm:7.1-prod as devilbox-slim-base
224250
ARG ARCH
225251

226252
###
227-
### Copy shared libraries
253+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
228254
###
229255
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
230256
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

Dockerfiles/slim/Dockerfile-7.2

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,32 @@ RUN set -eux \
207207
cp -r /usr/bin/mongo* /tmp/mongo/; \
208208
fi
209209

210+
###
211+
### Strip debugging information to smallen filesize
212+
###
213+
RUN set -eux \
214+
&& STRIP_USR_BINS="blackfire mongo mysql redis sqlite" \
215+
&& STRIP_DIRS="/usr/lib/postgresql/ /usr/share/postgresql-common/ /tmp" \
216+
\
217+
&& for bin in ${STRIP_USR_BINS}; do \
218+
( \
219+
find /usr/bin/ -name "${bin}"* -type f -print0 \
220+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
221+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
222+
) \
223+
done \
224+
\
225+
&& for dir in ${STRIP_DIRS}; do \
226+
( \
227+
find ${dir} -type f -print0 \
228+
| xargs -n1 -0 -P$(getconf _NPROCESSORS_ONLN) sh -c \
229+
'if [ -f "${1}" ]; then echo "Strip: ${1}"; strip --strip-all -p "${1}" 2>/dev/null || true; fi' -- \
230+
) \
231+
done \
232+
\
233+
&& strip --strip-all -p /usr/local/bin/mhsendmail 2>/dev/null || true \
234+
&& strip --strip-all -p /usr/local/bin/mysqldump-secure 2>/dev/null || true
235+
210236

211237

212238
########################################################################################################################
@@ -224,7 +250,7 @@ FROM devilbox/php-fpm:7.2-prod as devilbox-slim-base
224250
ARG ARCH
225251

226252
###
227-
### Copy shared libraries
253+
### Copy shared libraries (required by MongoDB, MySQL, PostgreSQL and Redis)
228254
###
229255
COPY --from=devilbox-slim-base-builder /tmp/lib-gnu/ /lib/${ARCH}-linux-gnu/
230256
COPY --from=devilbox-slim-base-builder /tmp/usr-lib-gnu/ /usr/lib/${ARCH}-linux-gnu/

0 commit comments

Comments
 (0)