Skip to content

Commit 7819c24

Browse files
committed
Simplify "-apache" images by using the Debian apache2 packages
1 parent 21df8a5 commit 7819c24

16 files changed

+438
-222
lines changed

5.3/Dockerfile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
FROM buildpack-deps
1+
FROM buildpack-deps:jessie
2+
3+
RUN apt-get update && apt-get install -y curl && rm -r /var/lib/apt/lists/*
4+
5+
##<apache2>##
6+
##</apache2>##
27

38
RUN gpg --keyserver pgp.mit.edu --recv-keys 0B96609E270F565C13292B24C13C70B87267B52D 0A95E9A026542D53835E3F3A7DEC4E69FC9C83D7
49

510
ENV PHP_VERSION 5.3.29
611

712
# php 5.3 needs older autoconf
813
RUN set -x \
9-
&& apt-get update && apt-get install -y autoconf2.13 curl && rm -r /var/lib/apt/lists/* \
14+
&& apt-get update && apt-get install -y autoconf2.13 && rm -r /var/lib/apt/lists/* \
1015
&& curl -SLO http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb \
1116
&& curl -SLO http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb \
1217
&& dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb \
@@ -16,15 +21,19 @@ RUN set -x \
1621
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.bz2.asc/from/this/mirror" -o php.tar.bz2.asc \
1722
&& gpg --verify php.tar.bz2.asc \
1823
&& mkdir -p /usr/src/php \
19-
&& tar -xvf php.tar.bz2 -C /usr/src/php --strip-components=1 \
24+
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
2025
&& rm php.tar.bz2* \
2126
&& cd /usr/src/php \
2227
&& ./buildconf --force \
2328
&& ./configure --disable-cgi \
29+
$(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \
30+
--with-mysql \
31+
--with-mysqli \
32+
--with-pdo-mysql \
2433
&& make -j"$(nproc)" \
2534
&& make install \
2635
&& dpkg -r bison libbison-dev \
27-
&& apt-get purge -y --auto-remove autoconf2.13 curl \
36+
&& apt-get purge -y --auto-remove autoconf2.13 \
2837
&& rm -r /usr/src/php
2938

3039
CMD ["php", "-a"]

5.3/apache/Dockerfile

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1-
FROM buildpack-deps
1+
FROM buildpack-deps:jessie
2+
3+
RUN apt-get update && apt-get install -y curl && rm -r /var/lib/apt/lists/*
4+
5+
##<apache2>##
6+
RUN apt-get update && apt-get install -y apache2-bin apache2-dev apache2.2-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
7+
8+
RUN rm -rf /var/www/html && mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html && chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html
9+
10+
# Apache + PHP requires preforking Apache for best results
11+
RUN a2dismod mpm_event && a2enmod mpm_prefork
12+
13+
RUN mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.dist
14+
COPY apache2.conf /etc/apache2/apache2.conf
15+
##</apache2>##
216

317
RUN gpg --keyserver pgp.mit.edu --recv-keys 0B96609E270F565C13292B24C13C70B87267B52D 0A95E9A026542D53835E3F3A7DEC4E69FC9C83D7
418

519
ENV PHP_VERSION 5.3.29
620

721
# php 5.3 needs older autoconf
822
RUN set -x \
9-
&& apt-get update && apt-get install -y autoconf2.13 curl && rm -r /var/lib/apt/lists/* \
23+
&& apt-get update && apt-get install -y autoconf2.13 && rm -r /var/lib/apt/lists/* \
1024
&& curl -SLO http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb \
1125
&& curl -SLO http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb \
1226
&& dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb \
@@ -16,54 +30,23 @@ RUN set -x \
1630
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.bz2.asc/from/this/mirror" -o php.tar.bz2.asc \
1731
&& gpg --verify php.tar.bz2.asc \
1832
&& mkdir -p /usr/src/php \
19-
&& tar -xvf php.tar.bz2 -C /usr/src/php --strip-components=1 \
33+
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
2034
&& rm php.tar.bz2* \
2135
&& cd /usr/src/php \
2236
&& ./buildconf --force \
2337
&& ./configure --disable-cgi \
38+
$(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \
39+
--with-mysql \
40+
--with-mysqli \
41+
--with-pdo-mysql \
2442
&& make -j"$(nproc)" \
2543
&& make install \
26-
\
27-
&& cd / \
28-
&& gpg --keyserver pgp.mit.edu --recv-keys A93D62ECC3C8EA12DB220EC934EA76E6791485A8 \
29-
&& apt-get update && apt-get install -y libapr1-dev libaprutil1-dev && rm -r /var/lib/apt/lists/* \
30-
&& curl -SL "http://apache.osuosl.org/httpd/httpd-2.4.10.tar.bz2" -o httpd.tar.bz2 \
31-
&& curl -SL "https://www.apache.org/dist/httpd/httpd-2.4.10.tar.bz2.asc" -o httpd.tar.bz2.asc \
32-
&& gpg --verify httpd.tar.bz2.asc \
33-
&& mkdir -p /usr/src/httpd \
34-
&& tar -xvf httpd.tar.bz2 -C /usr/src/httpd --strip-components=1 \
35-
&& rm httpd.tar.bz2.* \
36-
&& cd /usr/src/httpd \
37-
&& ./configure --enable-so \
38-
&& make -j"$(nproc)" \
39-
&& make install \
40-
&& cd / \
41-
&& rm -r /usr/src/httpd \
42-
&& mkdir -p /var/www/html \
43-
&& sed -r ' \
44-
s/(DirectoryIndex index[.])html/\1php/; \
45-
s!/usr/local/apache2/htdocs!/var/www/html!g; \
46-
s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \
47-
s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \
48-
$ a<FilesMatch \\.php$>\n\tSetHandler application/x-httpd-php\n</FilesMatch> \
49-
' /usr/local/apache2/conf/httpd.conf > /etc/apache2/httpd.conf \
50-
&& rm /usr/local/apache2/conf/httpd.conf \
51-
&& ln -s /etc/apache2/httpd.conf /usr/local/apache2/conf/httpd.conf \
52-
&& echo "<html><head></head><body><?php echo '<h1>Hello, World!</h1>'; ?></body></html>" >> /var/www/html/index.php \
53-
&& cd /usr/src/php \
54-
&& make clean \
55-
&& ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-pdo-mysql \
56-
&& make -j"$(nproc)" \
57-
&& make install \
58-
&& cp php.ini-development /usr/local/lib/php.ini \
5944
&& dpkg -r bison libbison-dev \
60-
&& apt-get purge -y --auto-remove autoconf2.13 curl \
45+
&& apt-get purge -y --auto-remove autoconf2.13 \
6146
&& rm -r /usr/src/php
6247

63-
ENV PATH $PATH:/usr/local/apache2/bin
64-
6548
WORKDIR /var/www/html
6649
VOLUME /var/www/html
6750

6851
EXPOSE 80
69-
CMD ["httpd", "-DFOREGROUND"]
52+
CMD ["apache2", "-DFOREGROUND"]

5.3/apache/apache2.conf

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
2+
3+
Mutex file:/var/lock/apache2 default
4+
PidFile /var/run/apache2/apache2.pid
5+
Timeout 300
6+
KeepAlive On
7+
MaxKeepAliveRequests 100
8+
KeepAliveTimeout 5
9+
User www-data
10+
Group www-data
11+
HostnameLookups Off
12+
ErrorLog /proc/self/fd/2
13+
LogLevel warn
14+
15+
IncludeOptional mods-enabled/*.load
16+
IncludeOptional mods-enabled/*.conf
17+
18+
# ports.conf
19+
Listen 80
20+
<IfModule ssl_module>
21+
Listen 443
22+
</IfModule>
23+
<IfModule mod_gnutls.c>
24+
Listen 443
25+
</IfModule>
26+
27+
<Directory />
28+
Options FollowSymLinks
29+
AllowOverride None
30+
Require all denied
31+
</Directory>
32+
33+
<Directory /var/www/>
34+
Options Indexes FollowSymLinks
35+
AllowOverride All
36+
Require all granted
37+
</Directory>
38+
39+
AccessFileName .htaccess
40+
<FilesMatch "^\.ht">
41+
Require all denied
42+
</FilesMatch>
43+
44+
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
45+
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
46+
LogFormat "%h %l %u %t \"%r\" %>s %O" common
47+
LogFormat "%{Referer}i -> %U" referer
48+
LogFormat "%{User-agent}i" agent
49+
50+
CustomLog /proc/self/fd/1 combined
51+
52+
<FilesMatch \.php$>
53+
SetHandler application/x-httpd-php
54+
</FilesMatch>
55+
DirectoryIndex index.php
56+
57+
DocumentRoot /var/www/html

5.4/Dockerfile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
FROM buildpack-deps
1+
FROM buildpack-deps:jessie
2+
3+
RUN apt-get update && apt-get install -y curl && rm -r /var/lib/apt/lists/*
4+
5+
##<apache2>##
6+
##</apache2>##
27

38
RUN gpg --keyserver pgp.mit.edu --recv-keys F38252826ACD957EF380D39F2F7956BC5DA04B5D
49

510
ENV PHP_VERSION 5.4.32
611

712
RUN set -x \
8-
&& apt-get update && apt-get install -y curl && rm -r /var/lib/apt/lists/* \
913
&& curl -SLO http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb \
1014
&& curl -SLO http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb \
1115
&& dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb \
@@ -15,15 +19,18 @@ RUN set -x \
1519
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.bz2.asc/from/this/mirror" -o php.tar.bz2.asc \
1620
&& gpg --verify php.tar.bz2.asc \
1721
&& mkdir -p /usr/src/php \
18-
&& tar -xvf php.tar.bz2 -C /usr/src/php --strip-components=1 \
22+
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
1923
&& rm php.tar.bz2* \
2024
&& cd /usr/src/php \
2125
&& ./buildconf --force \
2226
&& ./configure --disable-cgi \
27+
$(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \
28+
--with-mysql \
29+
--with-mysqli \
30+
--with-pdo-mysql \
2331
&& make -j"$(nproc)" \
2432
&& make install \
2533
&& dpkg -r bison libbison-dev \
26-
&& apt-get purge -y --auto-remove curl \
2734
&& rm -r /usr/src/php
2835

2936
CMD ["php", "-a"]

5.4/apache/Dockerfile

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
FROM buildpack-deps
1+
FROM buildpack-deps:jessie
2+
3+
RUN apt-get update && apt-get install -y curl && rm -r /var/lib/apt/lists/*
4+
5+
##<apache2>##
6+
RUN apt-get update && apt-get install -y apache2-bin apache2-dev apache2.2-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
7+
8+
RUN rm -rf /var/www/html && mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html && chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html
9+
10+
# Apache + PHP requires preforking Apache for best results
11+
RUN a2dismod mpm_event && a2enmod mpm_prefork
12+
13+
RUN mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.dist
14+
COPY apache2.conf /etc/apache2/apache2.conf
15+
##</apache2>##
216

317
RUN gpg --keyserver pgp.mit.edu --recv-keys F38252826ACD957EF380D39F2F7956BC5DA04B5D
418

519
ENV PHP_VERSION 5.4.32
620

721
RUN set -x \
8-
&& apt-get update && apt-get install -y curl && rm -r /var/lib/apt/lists/* \
922
&& curl -SLO http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb \
1023
&& curl -SLO http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb \
1124
&& dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb \
@@ -15,54 +28,22 @@ RUN set -x \
1528
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.bz2.asc/from/this/mirror" -o php.tar.bz2.asc \
1629
&& gpg --verify php.tar.bz2.asc \
1730
&& mkdir -p /usr/src/php \
18-
&& tar -xvf php.tar.bz2 -C /usr/src/php --strip-components=1 \
31+
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
1932
&& rm php.tar.bz2* \
2033
&& cd /usr/src/php \
2134
&& ./buildconf --force \
2235
&& ./configure --disable-cgi \
36+
$(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \
37+
--with-mysql \
38+
--with-mysqli \
39+
--with-pdo-mysql \
2340
&& make -j"$(nproc)" \
2441
&& make install \
25-
\
26-
&& cd / \
27-
&& gpg --keyserver pgp.mit.edu --recv-keys A93D62ECC3C8EA12DB220EC934EA76E6791485A8 \
28-
&& apt-get update && apt-get install -y libapr1-dev libaprutil1-dev && rm -r /var/lib/apt/lists/* \
29-
&& curl -SL "http://apache.osuosl.org/httpd/httpd-2.4.10.tar.bz2" -o httpd.tar.bz2 \
30-
&& curl -SL "https://www.apache.org/dist/httpd/httpd-2.4.10.tar.bz2.asc" -o httpd.tar.bz2.asc \
31-
&& gpg --verify httpd.tar.bz2.asc \
32-
&& mkdir -p /usr/src/httpd \
33-
&& tar -xvf httpd.tar.bz2 -C /usr/src/httpd --strip-components=1 \
34-
&& rm httpd.tar.bz2.* \
35-
&& cd /usr/src/httpd \
36-
&& ./configure --enable-so \
37-
&& make -j"$(nproc)" \
38-
&& make install \
39-
&& cd / \
40-
&& rm -r /usr/src/httpd \
41-
&& mkdir -p /var/www/html \
42-
&& sed -r ' \
43-
s/(DirectoryIndex index[.])html/\1php/; \
44-
s!/usr/local/apache2/htdocs!/var/www/html!g; \
45-
s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \
46-
s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \
47-
$ a<FilesMatch \\.php$>\n\tSetHandler application/x-httpd-php\n</FilesMatch> \
48-
' /usr/local/apache2/conf/httpd.conf > /etc/apache2/httpd.conf \
49-
&& rm /usr/local/apache2/conf/httpd.conf \
50-
&& ln -s /etc/apache2/httpd.conf /usr/local/apache2/conf/httpd.conf \
51-
&& echo "<html><head></head><body><?php echo '<h1>Hello, World!</h1>'; ?></body></html>" >> /var/www/html/index.php \
52-
&& cd /usr/src/php \
53-
&& make clean \
54-
&& ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-pdo-mysql \
55-
&& make -j"$(nproc)" \
56-
&& make install \
57-
&& cp php.ini-development /usr/local/lib/php.ini \
5842
&& dpkg -r bison libbison-dev \
59-
&& apt-get purge -y --auto-remove curl \
6043
&& rm -r /usr/src/php
6144

62-
ENV PATH $PATH:/usr/local/apache2/bin
63-
6445
WORKDIR /var/www/html
6546
VOLUME /var/www/html
6647

6748
EXPOSE 80
68-
CMD ["httpd", "-DFOREGROUND"]
49+
CMD ["apache2", "-DFOREGROUND"]

5.4/apache/apache2.conf

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
2+
3+
Mutex file:/var/lock/apache2 default
4+
PidFile /var/run/apache2/apache2.pid
5+
Timeout 300
6+
KeepAlive On
7+
MaxKeepAliveRequests 100
8+
KeepAliveTimeout 5
9+
User www-data
10+
Group www-data
11+
HostnameLookups Off
12+
ErrorLog /proc/self/fd/2
13+
LogLevel warn
14+
15+
IncludeOptional mods-enabled/*.load
16+
IncludeOptional mods-enabled/*.conf
17+
18+
# ports.conf
19+
Listen 80
20+
<IfModule ssl_module>
21+
Listen 443
22+
</IfModule>
23+
<IfModule mod_gnutls.c>
24+
Listen 443
25+
</IfModule>
26+
27+
<Directory />
28+
Options FollowSymLinks
29+
AllowOverride None
30+
Require all denied
31+
</Directory>
32+
33+
<Directory /var/www/>
34+
Options Indexes FollowSymLinks
35+
AllowOverride All
36+
Require all granted
37+
</Directory>
38+
39+
AccessFileName .htaccess
40+
<FilesMatch "^\.ht">
41+
Require all denied
42+
</FilesMatch>
43+
44+
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
45+
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
46+
LogFormat "%h %l %u %t \"%r\" %>s %O" common
47+
LogFormat "%{Referer}i -> %U" referer
48+
LogFormat "%{User-agent}i" agent
49+
50+
CustomLog /proc/self/fd/1 combined
51+
52+
<FilesMatch \.php$>
53+
SetHandler application/x-httpd-php
54+
</FilesMatch>
55+
DirectoryIndex index.php
56+
57+
DocumentRoot /var/www/html

0 commit comments

Comments
 (0)