forked from edyan/php-fpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-5.3
147 lines (137 loc) · 6.25 KB
/
Dockerfile-5.3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
FROM ubuntu:12.04
ARG DEBIAN_FRONTEND=noninteractive
# Set a default conf for apt-get install
RUN echo 'apt::install-recommends "false";' > /etc/apt/apt.conf.d/no-install-recommends && \
# Upgrade the system + Install all packages
apt-get update && \
# Install all packages below :
apt-get install -y \
# Calling fpm locally
libfcgi0ldbl \
# Manipulate iptables rules (example: block smtps)
iptables \
# PHP Modules
# php5-adodb \
# php5-auth-pam \
# php5-cgi \
php5-cli \
php5-curl \
# php5-dbg \
# php5-dev \
# php5-enchant \
# php5-exactimage \
# php5-ffmpeg \
php5-fpm \
php5-gd \
php5-geoip \
# php5-gmp \
php5-imagick \
php5-imap \
php5-interbase \
php5-intl \
# php5-lasso \
php5-ldap \
# php5-librdf \
# php5-mapscript \
php5-mcrypt \
php5-memcache \
php5-memcached \
# php5-midgard2 \
# php5-ming \
php5-mysql \
# php5-mysqlnd \
# php5-odbc \
php5-pgsql \
# php5-ps \
php5-pspell \
# php5-radius \
# php5-recode \
# php5-remctl \
# php5-rrd \
# php5-sasl \
# php5-snmp \
php5-sqlite \
# php5-suhosin \
# php5-svn \
# php5-sybase \
php5-tidy \
# php5-tokyo-tyrant \
# php5-uuid \
# php5-xcache \
php5-xdebug \
php5-xmlrpc \
php5-xsl \
php-apc \
libssh2-php && \
# Set a symlink to simplify the configuration, as we use a single php version
mkdir -p /etc/php && ln -s /etc/php5 /etc/php/current && \
# Log to stdout
sed -i 's/^error_log.*/error_log = \/proc\/self\/fd\/2/g' /etc/php/current/fpm/php-fpm.conf && \
echo 'access.log = /proc/self/fd/2' >> /etc/php/current/fpm/php-fpm.conf && \
# Create log dir
mkdir /var/log/php && \
# Build tools
apt-get install --force-yes -y build-essential pkg-config libssl-dev php-pear php5-dev && \
# pear for mongo
pecl channel-update pecl.php.net && \
pecl install mongo redis-4.3.0 xhprof-0.9.4 && \
rm -Rf /tmp/pear && \
# Patch too look like php 5.4
mv /etc/php5/conf.d /etc/php5/mods-available && mkdir /etc/php5/conf.d && \
# Create extension conf
echo "extension=mongo.so" > /etc/php/current/mods-available/mongo.ini && \
echo "extension=redis.so" > /etc/php/current/mods-available/redis.ini && \
echo "extension=xhprof.so" > /etc/php/current/mods-available/xhprof.ini && \
# Clean
apt-get purge build-essential pkg-config libssl-dev php-pear php5-dev -y && \
apt-get autoremove -y && apt-get autoclean && apt-get clean && \
# Empty some directories from all files and hidden files
rm -rf /build /usr/share/php/docs /usr/share/php/tests /tmp/* && \
find /root /var/lib/apt/lists /usr/share/man /usr/share/doc /var/cache /var/log -type f -delete
# Manage modules activation / deactivation
COPY --from=edyan/php:5.4 /usr/sbin/php5enmod /usr/sbin/php5enmod
COPY --from=edyan/php:5.4 /usr/sbin/php5dismod /usr/sbin/php5dismod
# Get configuration
COPY files/common/php-cli.ini /etc/php/current/cli/conf.d/30-custom-php.ini
COPY files/common/php-fpm.ini /etc/php/current/fpm/conf.d/30-custom-php.ini
COPY files/common/www.conf /etc/php/current/fpm/pool.d/
# Activate / deactivate modules and set configuration
RUN EXT_DIR=$(php -i | grep ^extension_dir | cut -d'=' -f2 | cut -d' ' -f2) && \
for MODULE in $(ls -1 ${EXT_DIR}|cut -d'.' -f1); do php5enmod ${MODULE}; done && \
# Patch to look like PHP 5.4
chmod +x /usr/sbin/php5*mod && \
# Rename and fix what is wrong
sed -i 's/;daemonize = yes/daemonize = no/g' /etc/php/current/fpm/php-fpm.conf && \
sed -i 's/^#/;/g' /etc/php/current/mods-available/interbase.ini && \
# For custom Configuration that comes from outside (via a docker compose mount)
mkdir /etc/php/current/fpm/user-conf.d && \
echo "; Default empty file" > /etc/php/current/fpm/user-conf.d/example.conf && \
# Create home for www-data
mkdir /home/www-data && \
chown www-data:www-data /home/www-data && \
usermod -d /home/www-data www-data && \
mkdir -p /run/php && \
chown www-data:www-data /run/php
COPY files/5.x/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENV ENVIRONMENT dev
ENV PHP_ENABLED_MODULES ""
ENV FPM_UID 33
ENV FPM_GID 33
EXPOSE 9000
# At the end as it changes everytime ;)
ARG BUILD_DATE
ARG DOCKER_TAG
ARG VCS_REF
LABEL maintainer="Emmanuel Dyan <[email protected]>" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name=${DOCKER_TAG} \
org.label-schema.description="Docker PHP Image based on Debian and including main modules" \
org.label-schema.url="https://cloud.docker.com/u/edyan/repository/docker/edyan/php" \
org.label-schema.vcs-url="https://github.com/edyan/docker-php" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.schema-version="1.0" \
org.label-schema.vendor="edyan" \
org.label-schema.docker.cmd="docker run -d --rm ${DOCKER_TAG}"
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/usr/sbin/php5-fpm", "-c", "/etc/php/current/fpm"]