Skip to content

Commit eef53e6

Browse files
committed
Merge branch 'documentation' into develop
* documentation: Remove unused rule from Makefile Add CHANGELOG.md and .dockerignore Adjust vars in Makefile Add README.md Extract Honcho deps and reduce size Add final cleanup instructions Refactor to a single `RUN` layer Remove Supvervisord
2 parents 18139fb + 561b079 commit eef53e6

File tree

5 files changed

+89
-50
lines changed

5 files changed

+89
-50
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.editorconfig
2+
CHANGELOG.md
3+
LICENSE
4+
Makefile
5+
README.md

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
TAG NOVERSION (UNRELEASED)
2+
3+
Initial release
4+
Compile Nginx v1.11.6 from source
5+
Compile PHP with PHP-FPM v7.0.13 from source.
6+
Install most recent version of PHP composer (as of 2016-12-01 v1.2.2).
7+
Install Honcho for process monitoring.

Dockerfile

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ 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 && \
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
214220
ENTRYPOINT ["/docker-entrypoint"]

Makefile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
REPO = rtucek
2-
IMAGE = nginx-php
3-
VERSION = 1.0.0
4-
EXTRAVERSION = -unreleased-wip
1+
REPO = janus1990
2+
IMAGE = docker-nginx-php
3+
VERSION = 0.1.0
4+
EXTRAVERSION = -dev
55

66
IMAGE_FQN = $(REPO)/$(IMAGE):$(VERSION)$(EXTRAVERSION)
77

@@ -11,6 +11,3 @@ default: build
1111

1212
build:
1313
docker build -t $(IMAGE_FQN) .
14-
15-
# tag_latest:
16-
# docker tag -f $(NAME):$(VERSION) $(NAME):latest

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## nginx-php Dockerfile
2+
3+
This repository contains source code of [janus1990/docker-nginx-php/](https://hub.docker.com/r/janus1990/docker-nginx-php/).
4+
5+
## Content
6+
7+
Nginx and PHP are compiled in a specific version. Consult the [CHANGELOG.md](./CHANGELOG.md) file
8+
for further version details. [PHP Composer](https://getcomposer.org/) is already installed and ready
9+
for use.
10+
11+
The Nginx and PHP-FPM master processes are controlled by [Honcho](https://github.com/nickstenning/honcho).
12+
Honcho was chosen over Supervisor, because honcho will exit and kill the container if either Nginx
13+
or PHP's master process dye for any reason. If you want have to have the container restarted
14+
automatically, you may want to use
15+
[Docker's restart](https://docs.docker.com/engine/reference/run/#restart-policies---restart) policy.
16+
17+
## Usage
18+
19+
```bash
20+
docker run -v /path/to/php/source/:/usr/local/nginx/html/ janus1990/docker-nginx-php
21+
22+
# With restart policy
23+
docker run --restart=always -v /path/to/php/source/:/usr/local/nginx/html/ janus1990/docker-nginx-php
24+
```

0 commit comments

Comments
 (0)