Skip to content

Commit 319dadf

Browse files
authored
Merge pull request #50 from devilbox/release-0.54
Shrink images
2 parents e698c91 + 6cf52ad commit 319dadf

File tree

2 files changed

+241
-167
lines changed

2 files changed

+241
-167
lines changed

Dockerfiles/Dockerfile.jessie

Lines changed: 124 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,79 @@ FROM debian:jessie-slim
22
MAINTAINER "cytopia" <[email protected]>
33

44

5-
ENV PHP_VERSION 5.2.17
6-
ENV PHP_INI_DIR /usr/local/etc/php
7-
8-
ENV BUILD_DEPS \
9-
autoconf2.13 \
10-
libbison-dev \
11-
libcurl4-openssl-dev \
12-
libfl-dev \
13-
libmysqlclient-dev \
14-
libpcre3-dev \
15-
libreadline6-dev \
16-
librecode-dev \
17-
libsqlite3-dev \
18-
libssl-dev \
19-
libxml2-dev \
20-
patch
21-
22-
23-
# Setup directories
24-
RUN set -eux \
25-
&& mkdir -p ${PHP_INI_DIR}/conf.d \
26-
&& mkdir -p /usr/src/php
27-
28-
29-
# persistent / runtime deps
5+
ENV PHP_VERSION=5.2.17
6+
ENV PHP_INI_DIR=/usr/local/etc/php
7+
8+
ENV OPENSSL_VERSION=1.0.2g
9+
10+
ENV PHP_BUILD_DEPS \
11+
autoconf2.13 \
12+
libbison-dev \
13+
libcurl4-openssl-dev \
14+
libfl-dev \
15+
libmysqlclient-dev \
16+
libpcre3-dev \
17+
libreadline6-dev \
18+
librecode-dev \
19+
libsqlite3-dev \
20+
libssl-dev \
21+
libxml2-dev
22+
23+
ENV PHP_RUNTIME_DEPS \
24+
libmysqlclient18 \
25+
libpcre3 \
26+
librecode0 \
27+
libsqlite3-0 \
28+
libssl1.0.0 \
29+
libxml2 \
30+
xz-utils
31+
32+
ENV BUILD_TOOLS \
33+
autoconf \
34+
ca-certificates \
35+
curl \
36+
dpkg-dev \
37+
file \
38+
flex \
39+
g++ \
40+
gcc \
41+
libc-dev \
42+
make \
43+
patch \
44+
pkg-config \
45+
re2c \
46+
xz-utils
47+
48+
ENV BUILD_TOOLS_32 \
49+
g++-multilib \
50+
gcc-multilib
51+
52+
ENV RUNTIME_TOOLS \
53+
ca-certificates \
54+
curl
55+
56+
57+
###
58+
### Build OpenSSL
59+
###
3060
RUN set -eux \
61+
# Install Dependencies
3162
&& apt-get update \
3263
&& apt-get install -y --no-install-recommends --no-install-suggests \
33-
ca-certificates \
34-
curl \
35-
libpcre3 \
36-
librecode0 \
37-
libmysqlclient18 \
38-
libsqlite3-0 \
39-
libxml2 \
40-
&& apt-get clean \
41-
&& rm -r /var/lib/apt/lists/*
42-
43-
44-
# phpize deps
45-
RUN set -eux \
46-
&& apt-get update \
47-
&& apt-get install -y --no-install-recommends --no-install-suggests \
48-
autoconf \
49-
dpkg-dev \
50-
file \
51-
g++ \
52-
gcc \
53-
libc-dev \
54-
make \
55-
pkg-config \
56-
re2c \
57-
xz-utils \
64+
${BUILD_TOOLS} \
5865
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \
5966
apt-get install -y --no-install-recommends --no-install-suggests \
60-
g++-multilib \
61-
gcc-multilib; \
67+
${BUILD_TOOLS_32}; \
6268
fi \
63-
&& apt-get clean \
64-
&& rm -r /var/lib/apt/lists/*
65-
66-
67-
# compile openssl, otherwise --with-openssl won't work
68-
RUN set -eux \
69-
&& OPENSSL_VERSION="1.0.2g" \
69+
# Fetch OpenSSL
7070
&& cd /tmp \
7171
&& mkdir openssl \
7272
&& update-ca-certificates \
7373
&& curl -sS -k -L --fail "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" -o openssl.tar.gz \
7474
&& curl -sS -k -L --fail "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz.asc" -o openssl.tar.gz.asc \
7575
&& tar -xzf openssl.tar.gz -C openssl --strip-components=1 \
7676
&& cd /tmp/openssl \
77+
# Build OpenSSL
7778
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \
7879
setarch i386 ./config -m32; \
7980
else \
@@ -82,27 +83,53 @@ RUN set -eux \
8283
&& make depend \
8384
&& make -j"$(nproc)" \
8485
&& make install \
85-
&& rm -rf /tmp/openssl* \
86+
# Cleanup
87+
&& rm -rf /tmp/* \
8688
# Ensure libs are linked to correct architecture directory
8789
&& debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" \
8890
&& mkdir -p "/usr/local/ssl/lib/${debMultiarch}" \
89-
&& ln -s /usr/local/ssl/lib/* "/usr/local/ssl/lib/${debMultiarch}/"
91+
&& ln -s /usr/local/ssl/lib/* "/usr/local/ssl/lib/${debMultiarch}/" \
92+
# Remove Dependencies
93+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \
94+
${BUILD_TOOLS} \
95+
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \
96+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \
97+
${BUILD_TOOLS_32}; \
98+
fi \
99+
&& apt-get clean \
100+
&& rm -rf /var/lib/apt/lists/*
90101

91102

92-
# php 5.2 needs older autoconf
103+
###
104+
### Setup PHP directories
105+
###
93106
RUN set -eux \
94-
&& set -x \
95-
&& apt-get update \
96-
&& apt-get install -y --no-install-recommends --no-install-suggests \
97-
${BUILD_DEPS} \
98-
&& rm -rf /var/lib/apt/lists/*
107+
&& mkdir -p ${PHP_INI_DIR}/conf.d \
108+
&& mkdir -p /usr/src/php
99109

100110

101-
# Copy and apply patches to PHP
111+
###
112+
### Copy PHP scripts and patches
113+
###
114+
COPY data/docker-php-source /usr/local/bin/
102115
COPY data/php-${PHP_VERSION}*.patch /tmp/
116+
117+
118+
###
119+
### Build PHP
120+
###
103121
RUN set -eux \
122+
# Install Dependencies
123+
&& apt-get update \
124+
&& apt-get install -y --no-install-recommends --no-install-suggests \
125+
${PHP_BUILD_DEPS} \
126+
${BUILD_TOOLS} \
127+
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \
128+
apt-get install -y --no-install-recommends --no-install-suggests \
129+
${BUILD_TOOLS_32}; \
130+
fi \
131+
# Fetch PHP
104132
&& curl -sS -k -L --fail "http://museum.php.net/php5/php-${PHP_VERSION}.tar.gz" -o /usr/src/php.tar.gz \
105-
\
106133
# Extract artifacts
107134
&& tar -xf /usr/src/php.tar.gz -C /usr/src/php --strip-components=1 \
108135
# Apply patches
@@ -114,65 +141,75 @@ RUN set -eux \
114141
# Create php.tar.xz
115142
&& cd /usr/src \
116143
&& tar -cJf php.tar.xz php \
117-
# Clean-up
118144
&& rm -rf php php.tar.gz \
119-
&& rm -rf /tmp/php-*
120-
121-
122-
COPY data/docker-php-source /usr/local/bin/
123-
RUN set -eux \
145+
&& rm -rf /tmp/php-* \
146+
# Setup Requirements
124147
&& apt update \
125148
&& apt install --no-install-recommends --no-install-suggests \
126149
flex -y \
127150
&& docker-php-source extract \
128151
&& cd /usr/src/php \
152+
\
129153
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
130154
&& debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" \
131155
\
132156
# https://bugs.php.net/bug.php?id=74125
133157
&& if [ ! -d /usr/include/curl ]; then \
134158
ln -sT "/usr/include/${debMultiarch}/curl" /usr/local/include/curl; \
135159
fi \
136-
\
160+
# Build PHP
137161
&& ./configure \
138162
--host="${gnuArch}" \
139163
--with-libdir="/lib/${debMultiarch}/" \
140164
--with-config-file-path="${PHP_INI_DIR}" \
141165
--with-config-file-scan-dir="${PHP_INI_DIR}/conf.d" \
142166
--with-fpm-conf="/usr/local/etc/php-fpm.conf" \
167+
--enable-fpm \
143168
\
144169
--enable-fastcgi \
145-
--enable-fpm \
146170
--enable-force-cgi-redirect \
147171
\
148172
--enable-mbstring \
149-
--enable-pdo \
150173
--enable-soap \
174+
--enable-pdo \
151175
\
152-
--with-curl \
153176
--with-mysql \
154177
--with-mysqli \
178+
--with-curl \
155179
--with-openssl=/usr/local/ssl \
156180
--with-pdo-mysql \
157181
--with-readline \
158182
--with-zlib \
159183
&& make -j"$(nproc)" \
160184
&& make install \
161185
&& php -v \
162-
# Clean-up
163-
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
164-
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false ${BUILD_DEPS} \
186+
# Cleanup
165187
&& make clean \
166-
&& cd / \
167-
&& docker-php-source delete
188+
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
189+
&& docker-php-source delete \
190+
# Remove Dependencies
191+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \
192+
${PHP_BUILD_DEPS} \
193+
${BUILD_TOOLS} \
194+
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \
195+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \
196+
${BUILD_TOOLS_32}; \
197+
fi \
198+
# Install Run-time requirements
199+
&& apt-get update \
200+
&& apt-get install -y --no-install-recommends --no-install-suggests \
201+
${PHP_RUNTIME_DEPS} \
202+
${RUNTIME_TOOLS} \
203+
&& apt-get clean \
204+
&& rm -rf /var/lib/apt/lists/*
168205

169206

170-
WORKDIR /var/www/html
171207
COPY data/docker-php-* /usr/local/bin/
172208
COPY data/php-fpm /usr/local/sbin/php-fpm
209+
210+
WORKDIR /var/www/html
173211
COPY data/php-fpm.conf /usr/local/etc/
174212
COPY data/php.ini /usr/local/etc/php/php.ini
175213

176-
177214
EXPOSE 9000
178-
ENTRYPOINT ["php-fpm"]
215+
CMD ["php-fpm"]

0 commit comments

Comments
 (0)