Skip to content

Commit 8d7452a

Browse files
committed
Refactor to a single RUN layer
1 parent 38510ce commit 8d7452a

File tree

1 file changed

+29
-40
lines changed

1 file changed

+29
-40
lines changed

Dockerfile

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ ENV \
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+
713
RUN \
814
# Install tools, required for building
915
apt-get update && \
1016
apt-get install -y \
1117
# In general...
1218
build-essential \
1319
curl \
20+
python-pip \
1421

1522
# For Nginx
1623
libpcre3-dev \
@@ -31,17 +38,17 @@ RUN \
3138
# For PHP composer
3239
git && \
3340

41+
pip install honcho && \
42+
3443
# Prepare for building
35-
mkdir -p /tmp/build
44+
mkdir -p /tmp/build && \
3645

37-
RUN \
3846
mkdir -p /tmp/build/nginx/ && \
3947
cd /tmp/build/nginx && \
4048

4149
# Download Nginx
42-
curl -SLO https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
50+
curl -SLO https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
4351

44-
RUN \
4552
cd /tmp/build/nginx && \
4653

4754
# GPG keys from the main maintainers of Nginx
@@ -61,14 +68,12 @@ RUN \
6168

6269
# Verify signature
6370
curl -SLO https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz.asc && \
64-
gpg nginx-${NGINX_VERSION}.tar.gz.asc
71+
gpg nginx-${NGINX_VERSION}.tar.gz.asc && \
6572

66-
RUN \
6773
cd /tmp/build/nginx && \
6874
# Unpack tarball
69-
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
75+
tar -xvzf nginx-${NGINX_VERSION}.tar.gz && \
7076

71-
RUN \
7277
cd /tmp/build/nginx/nginx-${NGINX_VERSION} && \
7378
# Run configuration
7479
./configure \
@@ -81,23 +86,23 @@ RUN \
8186
--with-http_ssl_module \
8287
--with-http_v2_module \
8388
--with-pcre \
84-
--with-threads
89+
--with-threads && \
8590

86-
RUN \
8791
cd /tmp/build/nginx/nginx-${NGINX_VERSION} && \
8892
# Start compiling and installing
8993
make -j$(nproc) build && \
9094
make modules && \
91-
make install
95+
make install && \
96+
97+
# Nginx configuration
98+
mv /tmp/build/scripts/nginx.conf /usr/local/nginx/conf/ && \
9299

93-
RUN \
94100
mkdir -p /tmp/build/php/ && \
95101
cd /tmp/build/php && \
96102

97103
# Download PHP
98-
curl -SLo php-${PHP_VERSION}.tar.gz http://ch1.php.net/get/php-${PHP_VERSION}.tar.gz/from/this/mirror
104+
curl -SLo php-${PHP_VERSION}.tar.gz http://ch1.php.net/get/php-${PHP_VERSION}.tar.gz/from/this/mirror && \
99105

100-
RUN \
101106
cd /tmp/build/php/ && \
102107

103108
# GPG keys from the release managers of PHP 7.0
@@ -107,14 +112,12 @@ RUN \
107112

108113
# Verify signature
109114
curl -SLo php-${PHP_VERSION}.tar.gz.asc http://ch1.php.net/get/php-${PHP_VERSION}.tar.gz.asc/from/this/mirror && \
110-
gpg php-${PHP_VERSION}.tar.gz.asc
115+
gpg php-${PHP_VERSION}.tar.gz.asc && \
111116

112-
RUN \
113117
cd /tmp/build/php && \
114118
# Unpack tarball
115-
tar -xvzf php-${PHP_VERSION}.tar.gz
119+
tar -xvzf php-${PHP_VERSION}.tar.gz && \
116120

117-
RUN \
118121
cd /tmp/build/php/php-${PHP_VERSION} && \
119122
# Run configuration
120123
./configure \
@@ -138,19 +141,13 @@ RUN \
138141
--with-pdo-pgsql \
139142
--with-readline \
140143
--with-xsl \
141-
--with-zlib
144+
--with-zlib && \
142145

143-
RUN \
144146
cd /tmp/build/php/php-${PHP_VERSION} && \
145147
# Compile, test and install
146148
make -j$(nproc) build && \
147-
make test && \
148-
make install
149+
make install && \
149150

150-
# Nginx configuration
151-
COPY nginx.conf /usr/local/nginx/conf/nginx.conf
152-
153-
RUN \
154151
# Fix permissions
155152
chown -R www-data:www-data /usr/local/nginx/html && \
156153

@@ -186,27 +183,19 @@ RUN \
186183
-e 's/^;?\s*opcache.enable_cli\s*=.*/opcache.enable_cli=1/' \
187184
-e 's/^;?\s*opcache.memory_consumption\s*=.*/opcache.memory_consumption = 256/' \
188185
-e 's/^;?\s*opcache.max_accelerated_files\s=.*/opcache.max_accelerated_files = 10000/' \
189-
/usr/local/php/php.ini
186+
/usr/local/php/php.ini && \
190187

191-
RUN \
192188
# Install PHP composer
193189
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
194190
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
195191
php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
196-
php -r "unlink('composer-setup.php');"
192+
php -r "unlink('composer-setup.php');" && \
197193

198-
# Install Honcho
199-
RUN \
200-
apt-get install -y \
201-
python-pip && \
202-
pip install honcho
194+
# Configure Honcho
195+
mv /tmp/build/scripts/Procfile / && \
203196

204-
# Configure Honcho
205-
COPY Procfile /
206-
207-
# Add entrypoint for docker
208-
COPY docker-entrypoint /
209-
RUN \
197+
# Add entrypoint for docker
198+
mv /tmp/build/scripts/docker-entrypoint / && \
210199
chmod +x /docker-entrypoint
211200

212201
# Declare entrypoint

0 commit comments

Comments
 (0)