forked from ezsystems/docker-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-7.4
148 lines (132 loc) · 5.54 KB
/
Dockerfile-7.4
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
148
FROM php:7.4-fpm-buster
# Container containing php-fpm and php-cli to run and interact with eZ Platform and other Symfony projects
#
# It has two modes of operation:
# - (run.sh cmd) [default] Reconfigure eZ Platform/Publish based on provided env variables and start php-fpm
# - (bash|php|composer) Allows to execute composer, php or bash against the image
# Set defaults for variables used by run.sh
ENV COMPOSER_HOME=/root/.composer
# Get packages that we need in container
RUN apt-get update -q -y \
&& apt-get install -q -y --no-install-recommends \
ca-certificates \
curl \
acl \
sudo \
# Disable expired Let's Encrypt certificate
&& sed -i '/mozilla\/DST_Root_CA_X3.crt/ s/./!&/' /etc/ca-certificates.conf \
&& update-ca-certificates --verbose \
# Needed for the php extensions we enable below
&& apt-get install -q -y --no-install-recommends \
libfreetype6 \
libjpeg62-turbo \
libxpm4 \
libpng16-16 \
libicu63 \
libxslt1.1 \
libmemcachedutil2 \
libzip4 \
imagemagick \
libonig5 \
libpq5 \
# git & unzip needed for composer, unless we document to use dev image for composer install
# unzip needed due to https://github.com/composer/composer/issues/4471
unzip \
git \
# packages useful for dev
less \
mariadb-client \
vim \
wget \
tree \
gdb-minimal \
&& rm -rf /var/lib/apt/lists/*
# Install and configure php plugins
RUN set -xe \
&& buildDeps=" \
$PHP_EXTRA_BUILD_DEPS \
libfreetype6-dev \
libjpeg62-turbo-dev \
libxpm-dev \
libpng-dev \
libicu-dev \
libxslt1-dev \
libmemcached-dev \
libzip-dev \
libxml2-dev \
libonig-dev \
libmagickwand-dev \
libpq-dev \
" \
&& apt-get update -q -y && apt-get install -q -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \
# Extract php source and install missing extensions
&& docker-php-source extract \
&& docker-php-ext-configure mysqli --with-mysqli=mysqlnd \
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-xpm=/usr/include/ --enable-gd-jis-conv \
&& docker-php-ext-install exif gd mbstring intl xsl zip mysqli pdo_mysql pdo_pgsql pgsql soap bcmath \
&& docker-php-ext-enable opcache \
&& cp /usr/src/php/php.ini-production ${PHP_INI_DIR}/php.ini \
\
# Install imagemagick
&& for i in $(seq 1 3); do pecl install -o imagick && s=0 && break || s=$? && sleep 1; done; (exit $s) \
&& docker-php-ext-enable imagick \
# Install xdebug
&& for i in $(seq 1 3); do echo yes | pecl install -o "xdebug" && s=0 && break || s=$? && sleep 1; done; (exit $s) \
# Install blackfire: https://blackfire.io/docs/integrations/docker
&& version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
&& mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
&& rm -f /tmp/blackfire-probe.tar.gz \
\
# Install igbinary (for more efficient serialization in redis/memcached)
&& for i in $(seq 1 3); do pecl install -o igbinary && s=0 && break || s=$? && sleep 1; done; (exit $s) \
&& docker-php-ext-enable igbinary \
\
# Install redis (manualy build in order to be able to enable igbinary)
&& for i in $(seq 1 3); do pecl install -o --nobuild redis && s=0 && break || s=$? && sleep 1; done; (exit $s) \
&& cd "$(pecl config-get temp_dir)/redis" \
&& phpize \
&& ./configure --enable-redis-igbinary \
&& make \
&& make install \
&& docker-php-ext-enable redis \
&& cd - \
\
# Install memcached (manualy build in order to be able to enable igbinary)
&& for i in $(seq 1 3); do echo no | pecl install -o --nobuild memcached && s=0 && break || s=$? && sleep 1; done; (exit $s) \
&& cd "$(pecl config-get temp_dir)/memcached" \
&& phpize \
&& ./configure --enable-memcached-igbinary \
&& make \
&& make install \
&& docker-php-ext-enable memcached \
&& cd - \
\
# Delete source & builds deps so it does not hang around in layers taking up space
&& pecl clear-cache \
&& rm -Rf "$(pecl config-get temp_dir)/*" \
&& docker-php-source delete \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps
# Set timezone
RUN echo "UTC" > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
# Set pid file to be able to restart php-fpm
RUN sed -i "s@^\[global\]@\[global\]\n\npid = /run/php-fpm.pid@" ${PHP_INI_DIR}-fpm.conf
COPY conf.d/blackfire.ini ${PHP_INI_DIR}/conf.d/blackfire.ini
COPY conf.d/xdebug.ini ${PHP_INI_DIR}/conf.d/xdebug.ini.disabled
# Create Composer directory (cache and auth files) & Get Composer
RUN mkdir -p $COMPOSER_HOME \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# As application is put in as volume we do all needed operation on run
COPY scripts /scripts
# Add some custom config
COPY conf.d/php.ini ${PHP_INI_DIR}/conf.d/php.ini
RUN chmod 755 /scripts/*.sh
# Needed for docker-machine
RUN usermod -u 1000 www-data
WORKDIR /var/www
ENTRYPOINT ["/scripts/docker-entrypoint.sh"]
CMD php-fpm
EXPOSE 9000