44 NGINX_VERSION=1.11.6 \
55 PHP_VERSION=7.0.13
66
7+ COPY \
8+ docker-entrypoint \
9+ nginx.conf \
10+ Procfile \
11+ /tmp/build/scripts/
12+
713RUN \
814 # Install tools, required for building
915 apt-get update && \
10- apt-get install -y \
16+ apt-get install -y --no-install-recommends \
1117 # In general...
1218 build-essential \
1319 curl \
14- supervisor \
1520
1621 # For Nginx
1722 libpcre3-dev \
@@ -30,19 +35,24 @@ RUN \
3035 re2c \
3136
3237 # For PHP composer
33- git && \
38+ git \
39+
40+ # For Honcho
41+ python \
42+ python-pip \
43+ python-pkg-resources && \
44+
45+ pip install honcho && \
3446
3547 # Prepare for building
36- mkdir -p /tmp/build
48+ mkdir -p /tmp/build && \
3749
38- RUN \
3950 mkdir -p /tmp/build/nginx/ && \
4051 cd /tmp/build/nginx && \
4152
4253 # Download Nginx
43- curl -SLO https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
54+ curl -SLO https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
4455
45- RUN \
4656 cd /tmp/build/nginx && \
4757
4858 # GPG keys from the main maintainers of Nginx
@@ -62,14 +72,12 @@ RUN \
6272
6373 # Verify signature
6474 curl -SLO https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc && \
65- gpg nginx-${NGINX_VERSION}.tar.gz.asc
75+ gpg nginx-${NGINX_VERSION}.tar.gz.asc && \
6676
67- RUN \
6877 cd /tmp/build/nginx && \
6978 # Unpack tarball
70- tar -xvzf nginx-${NGINX_VERSION}.tar.gz
79+ tar -xvzf nginx-${NGINX_VERSION}.tar.gz && \
7180
72- RUN \
7381 cd /tmp/build/nginx/nginx-${NGINX_VERSION} && \
7482 # Run configuration
7583 ./configure \
@@ -82,23 +90,23 @@ RUN \
8290 --with-http_ssl_module \
8391 --with-http_v2_module \
8492 --with-pcre \
85- --with-threads
93+ --with-threads && \
8694
87- RUN \
8895 cd /tmp/build/nginx/nginx-${NGINX_VERSION} && \
8996 # Start compiling and installing
9097 make -j$(nproc) build && \
9198 make modules && \
92- make install
99+ make install && \
100+
101+ # Nginx configuration
102+ mv /tmp/build/scripts/nginx.conf /usr/local/nginx/conf/ && \
93103
94- RUN \
95104 mkdir -p /tmp/build/php/ && \
96105 cd /tmp/build/php && \
97106
98107 # Download PHP
99- curl -SLo php-${PHP_VERSION}.tar.gz http://ch1.php.net/get/php-${PHP_VERSION}.tar.gz/from/this/mirror
108+ curl -SLo php-${PHP_VERSION}.tar.gz http://ch1.php.net/get/php-${PHP_VERSION}.tar.gz/from/this/mirror && \
100109
101- RUN \
102110 cd /tmp/build/php/ && \
103111
104112 # GPG keys from the release managers of PHP 7.0
@@ -108,14 +116,12 @@ RUN \
108116
109117 # Verify signature
110118 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
119+ gpg php-${PHP_VERSION}.tar.gz.asc && \
112120
113- RUN \
114121 cd /tmp/build/php && \
115122 # Unpack tarball
116- tar -xvzf php-${PHP_VERSION}.tar.gz
123+ tar -xvzf php-${PHP_VERSION}.tar.gz && \
117124
118- RUN \
119125 cd /tmp/build/php/php-${PHP_VERSION} && \
120126 # Run configuration
121127 ./configure \
@@ -139,19 +145,13 @@ RUN \
139145 --with-pdo-pgsql \
140146 --with-readline \
141147 --with-xsl \
142- --with-zlib
148+ --with-zlib && \
143149
144- RUN \
145150 cd /tmp/build/php/php-${PHP_VERSION} && \
146151 # Compile, test and install
147152 make -j$(nproc) build && \
148- make test && \
149- make install
150-
151- # Nginx configuration
152- COPY nginx.conf /usr/local/nginx/conf/nginx.conf
153+ make install && \
153154
154- RUN \
155155 # Fix permissions
156156 chown -R www-data:www-data /usr/local/nginx/html && \
157157
@@ -187,28 +187,34 @@ RUN \
187187 -e 's/^;?\s *opcache.enable_cli\s *=.*/opcache.enable_cli=1/' \
188188 -e 's/^;?\s *opcache.memory_consumption\s *=.*/opcache.memory_consumption = 256/' \
189189 -e 's/^;?\s *opcache.max_accelerated_files\s =.*/opcache.max_accelerated_files = 10000/' \
190- /usr/local/php/php.ini
190+ /usr/local/php/php.ini && \
191191
192- RUN \
193192 # Install PHP composer
194193 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
195194 php -r "if (hash_file('SHA384', 'composer-setup.php') === 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
196195 php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
197- php -r "unlink('composer-setup.php');"
196+ php -r "unlink('composer-setup.php');" && \
198197
199- # Install Honcho
200- RUN \
201- apt-get install -y \
202- python-pip && \
203- pip install honcho
198+ # Configure Honcho
199+ mv /tmp/build/scripts/Procfile / && \
204200
205- # Configure Honcho
206- COPY Procfile /
201+ # Add entrypoint for docker
202+ mv /tmp/build/scripts/docker-entrypoint / && \
203+ chmod +x /docker-entrypoint && \
207204
208- # Add entrypoint for docker
209- COPY docker-entrypoint /
210- RUN \
211- chmod +x /docker-entrypoint
205+ # Final cleanup
206+ apt-get remove -y \
207+ bison \
208+ build-essential \
209+ curl \
210+ pkg-config \
211+ python-pip \
212+ re2c && \
213+
214+ apt-get autoremove -y && \
215+
216+ rm -rf /var/lib/apt/lists/* && \
217+ rm -rf /tmp/build
212218
213219# Declare entrypoint
214220ENTRYPOINT ["/docker-entrypoint" ]
0 commit comments