Skip to content

Commit 401b53f

Browse files
committed
Added the license, wrote the readme, and fixed the containers accordingly.
1 parent 4220337 commit 401b53f

File tree

8 files changed

+104
-16
lines changed

8 files changed

+104
-16
lines changed

Dockerfile-5.6

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ MAINTAINER [email protected]
55
RUN apk -U upgrade && apk add \
66
curl \
77
nginx \
8-
php5 \
98
php5-fpm \
10-
&& rm -rf /var/cache/apk/* \
119
&& addgroup -S php \
12-
&& adduser -S -G php php
13-
10+
&& adduser -S -G php php \
11+
&& rm -rf /var/cache/apk/* /etc/nginx/conf.d/* /etc/php5/conf.d/* /etc/php5/php-fpm.d/*
1412

1513
COPY files/s6-overlay files/general files/php5 /
1614

Dockerfile-7.0

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ MAINTAINER [email protected]
55
RUN apk -U upgrade && apk add \
66
curl \
77
nginx \
8-
php7 \
98
php7-fpm \
10-
&& rm -rf /var/cache/apk/* \
119
&& addgroup -S php \
12-
&& adduser -S -G php php
10+
&& adduser -S -G php php \
11+
&& rm -rf /var/cache/apk/* /etc/nginx/conf.d/* /etc/php7/conf.d/* /etc/php7/php-fpm.d/*
1312

1413
COPY files/s6-overlay files/general files/php7 /
1514

Dockerfile-7.1

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ MAINTAINER [email protected]
55
RUN apk -U upgrade && apk add \
66
curl \
77
nginx \
8-
php7 \
98
php7-fpm \
10-
&& rm -rf /var/cache/apk/* \
119
&& addgroup -S php \
12-
&& adduser -S -G php php
10+
&& adduser -S -G php php \
11+
&& rm -rf /var/cache/apk/* /etc/nginx/conf.d/* /etc/php7/conf.d/* /etc/php7/php-fpm.d/*
1312

1413
COPY files/s6-overlay files/general files/php7 /
1514

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Stefan van Essen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+68-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,73 @@
1-
# eXistenZ' webstack container
1+
# Docker Builder
22

3-
A container running Nginx and PHP
3+
[![Docker Build Status](https://img.shields.io/travis/eXistenZNL/Docker-Webstack.svg?style=flat-square)](https://travis-ci.org/eXistenZNL/Docker-Webstack) [![Docker Pulls](https://img.shields.io/docker/pulls/existenz/webstack.svg?style=flat-square)](https://hub.docker.com/r/existenz/webstack/) [![License](https://img.shields.io/github/license/existenznl/docker-webstack.svg?style=flat-square)](https://github.com/eXistenZNL/Docker-Webstack/blob/master/LICENSE)
44

5-
## Why
5+
## About
6+
This container is a fairly simple Nginx / PHP-FPM container that can be used as a base for your own web containers. It makes use of [s6-overlay](https://github.com/just-containers/s6-overlay) as it's init daemon / process supervisor, and comes in three flavours: PHP 5.6, PHP 7.0 and PHP 7.1. It is rebuilt and tested every day on Travis-CI, so you will always have the latest security patches of Nginx and PHP on hand.
67

7-
## What
8+
## Why?
9+
I can hear you thinking "aren't there already plenty good Nginx / PHP containers out there?".
10+
To me, there weren't, as I found that all existing containers either run some kind of bash script to start both Nginx and PHP, or use [supervisord](http://supervisord.org/) to start one or more processes in the background.
11+
The former felt really hacky to me, and the latter is not meant to be used as an init daemon as [it does not handle the different signals for process 1 properly](https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/) and makes your container possibly end up with zombie processes.
812

9-
## How to use this container
13+
So I started looking for proper init daemons that can take care of this situation and I found [s6-overlay](https://github.com/just-containers/s6-overlay) which explains in great detail how they overcame the aforementioned problems.
1014

11-
### Advanced
15+
## The goals of this container
16+
17+
- Be always up to date with the latest [packages from Alpine Linux](https://pkgs.alpinelinux.org/packages)
18+
- Minimize the lines of code needed in your own Dockerfile and optimize readibility.
19+
- Have sane defaults for Nginx, PHP, and FPM that can be easily overwritten if needed.
20+
21+
## How can I use it?
22+
23+
You can create your own containers based upon this container with a simple FROM in your Dockerfile.
24+
25+
### Before you start
26+
27+
Before start hacking away, you should know this:
28+
- Nginx runs under the system's nginx user, and PHP-FPM runs under the system's php user.
29+
- The code should be copied into /www, as this is the default directory Nginx and PHP work with in this container.
30+
- Any PHP modules needed in your project should be installed by using apk, Alpine Linux's package manager and the package names for installing can be looked up [here](https://pkgs.alpinelinux.org).
31+
32+
Then there are some tips or rather guidelines that I adhere to personally, but ultimately this is just a matter of taste:
33+
- [S6-overlay can set permissions when the container starts up](https://github.com/just-containers/s6-overlay#fixing-ownership--permissions), but this can be slow if a lot of permissions need to be set, so just do this when building the container.
34+
35+
### Basic example
36+
Now that we know all that, we can do something like this:
37+
```
38+
FROM existenz/webstack:7.0
39+
40+
COPY src/ /www
41+
42+
RUN chown -R php:nginx /www \
43+
&& find /www -type d -exec chmod -R 555 {} \; \
44+
&& find /www -type f -exec chmod -R 444 {} \; \
45+
&& find /www/var -type d -exec chmod -R 755 {} \; \
46+
&& find /www/var -type f -exec chmod -R 644 {} \; \
47+
&& apk -U --no-cache add \
48+
php7-ctype \
49+
php7-json \
50+
php7-mbstring
51+
```
52+
And you should now have a working container that runs your PHP project!
53+
54+
### Overriding or extending the configuration
55+
56+
If you want to augment of replace the configuration of Nginx, PHP or FPM, there are multiple options:
57+
- Place one or more configuration files in specific directories to augment the configuration
58+
- If that does not suit your needs, you can also simply overwrite the configuration files altogether
59+
60+
These are the files to add or overwrite in order to configure the different parts of the webstack:
61+
62+
| Application | Copy files into this directory | Overwrite this file if needed |
63+
|---------------------------|--------------------------------|-------------------------------|
64+
| PHP core directives (5.6) | /etc/php5/conf.d/ | /etc/php5/php.ini |
65+
| PHP-FPM (5.6) | /etc/php5/php-fpm.d/ | /etc/php5/php-fpm.conf |
66+
| PHP core directives (7.x) | /etc/php7/conf.d/ | /etc/php7/php.ini |
67+
| PHP-FPM (7.x) | /etc/php7/php-fpm.d/ | /etc/php7/php-fpm.conf |
68+
| Nginx | /etc/nginx/conf.d/ | /etc/nginx/nginx.conf |
69+
70+
## Bugs, questions, and improvements
71+
72+
If you found a bug or have a question, please open an issue on the GitHub Issue tracker.
73+
Improvements can be sent by a Pull Request against the master branch and are greatly appreciated!

files/general/etc/nginx/nginx.conf

+3
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ http {
5454
}
5555
}
5656
}
57+
58+
# Include other configuration files
59+
include /etc/nginx/conf.d/*.conf;

files/php5/etc/php5/php-fpm.conf

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ pm.max_requests = 500
2424

2525
; Health check
2626
ping.path = /php-fpm-ping
27+
28+
; Include other configuration files
29+
include=/etc/php5/php-fpm.d/*.conf

files/php7/etc/php7/php-fpm.conf

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ pm.max_requests = 500
2424

2525
; Health check
2626
ping.path = /php-fpm-ping
27+
28+
; Include other configuration files
29+
include=/etc/php7/php-fpm.d/*.conf

0 commit comments

Comments
 (0)