@@ -11,21 +11,26 @@ RUN \
1111 # In general...
1212 build-essential \
1313 curl \
14+ supervisor \
1415
1516 # For Nginx
16- libssl-dev \
1717 libpcre3-dev \
18+ libssl-dev \
1819
1920 # For PHP
2021 bison \
2122 libbz2-dev \
2223 libcurl4-openssl-dev \
2324 libpng12-dev \
2425 libpq-dev \
26+ libreadline-dev \
2527 libxml2-dev \
2628 libxslt1-dev \
2729 pkg-config \
28- re2c && \
30+ re2c \
31+
32+ # For PHP composer
33+ git && \
2934
3035 # Prepare for building
3136 mkdir -p /tmp/build
3944
4045RUN \
4146 cd /tmp/build/nginx && \
42- # Verify signature
43- curl -SLO https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc && \
47+
48+ # GPG keys from the main maintainers of Nginx
49+ # Source https://nginx.org/en/pgp_keys.html
4450 curl -SLO https://nginx.org/keys/nginx_signing.key && \
4551 gpg --import nginx_signing.key && \
4652 curl -SLO https://nginx.org/keys/aalexeev.key && \
5359 gpg --import maxim.key && \
5460 curl -SLO https://nginx.org/keys/sb.key && \
5561 gpg --import sb.key && \
62+
63+ # Verify signature
64+ curl -SLO https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc && \
5665 gpg nginx-${NGINX_VERSION}.tar.gz.asc
5766
5867RUN \
6473 cd /tmp/build/nginx/nginx-${NGINX_VERSION} && \
6574 # Run configuration
6675 ./configure \
76+ --group=www-data \
77+ --user=www-data \
6778 --with-file-aio \
6879 --with-http_gunzip_module \
6980 --with-http_gzip_static_module \
8798 # Download PHP
8899 curl -SLo php-${PHP_VERSION}.tar.gz http://ch1.php.net/get/php-${PHP_VERSION}.tar.gz/from/this/mirror
89100
90- # RUN \
91- # TODO SIG VERIFICATION!!!
101+ RUN \
102+ cd /tmp/build/php/ && \
103+
104+ # GPG keys from the release managers of PHP 7.0
105+ # Source https://secure.php.net/gpg-keys.php#gpg-7.0
106+ gpg --keyserver pgp.mit.edu/ --recv "1A4E 8B72 77C4 2E53 DBA9 C7B9 BCAA 30EA 9C0D 5763" && \
107+ gpg --keyserver pgp.mit.edu/ --recv "6E4F 6AB3 21FD C07F 2C33 2E3A C2BF 0BC4 33CF C8B3" && \
108+
109+ # Verify signature
110+ curl -SLo php-${PHP_VERSION}.tar.gz.asc http://ch1.php.net/get/php-${PHP_VERSION}.tar.gz.asc/from/this/mirror && \
111+ gpg php-${PHP_VERSION}.tar.gz.asc
92112
93113RUN \
94114 cd /tmp/build/php && \
@@ -102,23 +122,102 @@ RUN \
102122 --enable-fpm \
103123 --enable-mbregex \
104124 --enable-mbstring \
125+ --enable-mbstring=all \
105126 --enable-opcache \
106127 --enable-sockets \
107128 --enable-zip \
129+ --enable-zip \
108130 --with-bz2 \
109131 --with-curl \
132+ --with-fpm-group=www-data \
133+ --with-fpm-user=www-data \
110134 --with-gd \
111135 --with-gettext \
112136 --with-openssl \
113137 --with-pcre-regex \
114138 --with-pdo-mysql \
115139 --with-pdo-pgsql \
140+ --with-readline \
116141 --with-xsl \
117142 --with-zlib
118143
119144RUN \
120145 cd /tmp/build/php/php-${PHP_VERSION} && \
121- # Compile, test and install.
146+ # Compile, test and install
122147 make -j$(nproc) build && \
123148 make test && \
124149 make install
150+
151+ # Nginx configuration
152+ COPY nginx.conf /usr/local/nginx/conf/nginx.conf
153+
154+ RUN \
155+ # Fix permissions
156+ chown -R www-data:www-data /usr/local/nginx/html && \
157+
158+ # Symlink Nginx binary
159+ ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ && \
160+
161+ # Copy PHP-FPM configuration files
162+ cp /tmp/build/php/php-${PHP_VERSION}/sapi/fpm/php-fpm.conf /usr/local/etc/php-fpm.conf && \
163+ cp /tmp/build/php/php-${PHP_VERSION}/sapi/fpm/www.conf /usr/local/etc/www.conf && \
164+ cp /tmp/build/php/php-${PHP_VERSION}/php.ini-development /usr/local/php/php.ini && \
165+
166+ # Patch PHP-FPM for proper loading www.conf
167+ sed -Ei \
168+ -e 's/^;?\s *daemonize\s *=\s *yes/daemonize = no/' \
169+ -e 's/^;?\s *include=NONE\/ etc\/ php-fpm.d\/\* .conf/include=\/ usr\/ local\/ etc\/ www.conf/' \
170+ /usr/local/etc/php-fpm.conf && \
171+
172+ # Patch www.conf config connection establishment
173+ sed -Ei \
174+ -e 's/^;?\s *listen\s *=.*/listen = \/ var\/ run\/ php-fpm.sock/' \
175+ -e 's/^;?\s *?\s *listen.owner\s *=.*/listen.owner = www-data/' \
176+ -e 's/^;?\s *?\s *listen.group\s *=.*/listen.group = www-data/' \
177+ -e 's/^;?\s *?\s *listen.mode\s *=.*/listen.mode = 0660/' \
178+ /usr/local/etc/www.conf && \
179+
180+ # Patch PHP config files on the fly
181+ sed -Ei \
182+ -e 's/^;?\s *expose_php\s *=.*/expose_php = Off/' \
183+ -e 's/^;?\s *cgi.fix_pathinfo\s *=.*/cgi.fix_pathinfo=0/' \
184+ -e 's/^;?\s *error_log\s *=.*/error_log = \/ usr\/ local\/ nginx\/ logs\/ error-php.log/' \
185+ -e 's/^;?\s *date.timezone\s *=.*/date.timezone = \" UTC\" /' \
186+ -e 's/^;?\s *opcache.enable\s *=.*/opcache.enable = 1/' \
187+ -e 's/^;?\s *opcache.enable_cli\s *=.*/opcache.enable_cli=1/' \
188+ -e 's/^;?\s *opcache.memory_consumption\s *=.*/opcache.memory_consumption = 256/' \
189+ -e 's/^;?\s *opcache.max_accelerated_files\s =.*/opcache.max_accelerated_files = 10000/' \
190+ /usr/local/php/php.ini
191+
192+ RUN \
193+ # Install PHP composer
194+ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
195+ php -r "if (hash_file('SHA384', 'composer-setup.php') === 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
196+ php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
197+ php -r "unlink('composer-setup.php');"
198+
199+ # Install Honcho
200+ RUN \
201+ apt-get install -y \
202+ python-pip && \
203+ pip install honcho
204+
205+ # Configure Honcho
206+ COPY Procfile /
207+
208+ # Add entrypoint for docker
209+ COPY docker-entrypoint /
210+ RUN \
211+ chmod +x /docker-entrypoint
212+
213+ # Declare entrypoint
214+ ENTRYPOINT ["/docker-entrypoint" ]
215+
216+ # Define default command
217+ CMD ["server" ]
218+
219+ # Define Workdir
220+ WORKDIR "/usr/local/nginx/html"
221+
222+ # Exposing ports
223+ EXPOSE 80/tcp 443/tcp
0 commit comments