<commit_before>## lemp-base - The ultimate base image for your dockerized PHP application

This is a base image for containerized PHP applications.

### Plain sample usage:

```console
$ docker run -d -p 80:80 gambitlabs/lemp-base:v0.4.0
```

This will run a webserver on `localhost` that is serving one page only:

```php
<?php
phpinfo();

```

with this nginx configuration:
```nginx
location / {
	include /etc/nginx/conf/php.conf;
}
```

Very straightforward. In order to produce a new image with the two above files, just do this:
```Dockerfile
FROM gambitlabs/lemp-base:v0.4.0
COPY nginx-conf/default-php.conf /etc/nginx/conf.d/index.conf
COPY index.php /var/www/html
```

### What's in it:

 - PHP 5.6
 - nginx 1.11.5
 - mysql
 - postfix

### Features

In order to discover all the features this image has, run the help command, and it will produce output like this:

```console
$ docker run -it gambitlabs/lemp-base:v0.4.0 help
Supported nginx variables and their defaults:
 - NGINX_DOMAIN_NAME=localhost: The domain name that nginx should listen to. May be a string with several whitespace-separated domain names.
 - NGINX_WORKER_PROCESSES=1: The amount of worker processes nginx should spawn.
 - NGINX_WORKER_CONNECTIONS=1024: The amount of worker connections one process may have open at a given time.

nginx version: 1.11.5
mysql client version: 10.1.18

Enabled/disabled features:
 - NGINX_ENABLE_HTTPS=0: If HTTPS should be enabled.
 - NGINX_ENABLE_HTTP2=0: If HTTP 2.0 should be enabled.
 - PHP_SERVER=: The PHP server nginx should pass requests to. Defaults to "", which means it will use the current.
 - MAIL_ENABLE=0: If postfix should be enabled
 - CRON_ENABLE=0/1: Default 0.

Supported PHP variables and their defaults:
 - PHP_MAX_EXECUTION_TIME=300: How many seconds a PHP request may take before it should timeout.
 - PHP_MAX_UPLOAD_SIZE=32: How many megabytes an user is allowed to upload to the server.
 - PHP_TIMEZONE=Europe/Helsinki: The timezone that should be set

PHP version: 5.6.28

Supported postfix variables and their defaults:
 - POSTFIX_DOMAIN: Mandatory. Which domain postfix should pretend to send from.
 - POSTFIX_SMTP_SERVER: Mandatory. The smtp server postfix should forward mail to.
 - POSTFIX_SMTP_PORT=25: The port of the smtp server.
 - POSTFIX_LOGIN_EMAIL=: The email address that should be used for login to the server.
 - POSTFIX_LOGIN_PASSWORD=: The password that should be used for login to the server.
 - POSTFIX_USE_TLS=0: If tls should be used.
 - POSTFIX_USE_PLAIN_ONLY=0: Makes postfix authenticate with the server via the PLAIN method.
 - POSTFIX_FOREGROUND=1: If this script should loop endlessly after postfix is started.

postfix version: 3.1.1
```

### Filesystem layout

WWW directory: `/var/www/html`. Here you should put all your website's data and nginx will serve it.
nginx configuration directory: `/etc/nginx/conf.d`. Here you should put your website's `location` directives.
Certificates directory: `/certs`. If you enable HTTPS or HTTP2, you should volume-mount in `/certs/site.crt` as the certificate and `/certs/site.key` as the private key. Optional file for even more security is `/certs/dhparam.pem` that nginx will use if present.

### Ubuntu 16.04 cloud-init

To build the image the following [cloud-config](https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting) can be used with a Digital Ocean Ubuntu 16.04 with at least 1 GB RAM:

```
#cloud-config
package_update: true
packages:
  - git
  - curl
  - make
  - wget
  - nano
  - software-properties-common
  - apt-transport-https
runcmd:
  - apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys <KEY>
  - apt-add-repository -y 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
  - apt-get update -y<commit_msg>Added note about using IPv6 support in DigitalOcean VM.<commit_after>## lemp-base - The ultimate base image for your dockerized PHP application

This is a base image for containerized PHP applications.

### Plain sample usage:

```console
$ docker run -d -p 80:80 gambitlabs/lemp-base:v0.4.0
```

This will run a webserver on `localhost` that is serving one page only:

```php
<?php
phpinfo();

```

with this nginx configuration:
```nginx
location / {
	include /etc/nginx/conf/php.conf;
}
```

Very straightforward. In order to produce a new image with the two above files, just do this:
```Dockerfile
FROM gambitlabs/lemp-base:v0.4.0
COPY nginx-conf/default-php.conf /etc/nginx/conf.d/index.conf
COPY index.php /var/www/html
```

### What's in it:

 - PHP 5.6
 - nginx 1.11.5
 - mysql
 - postfix

### Features

In order to discover all the features this image has, run the help command, and it will produce output like this:

```console
$ docker run -it gambitlabs/lemp-base:v0.4.0 help
Supported nginx variables and their defaults:
 - NGINX_DOMAIN_NAME=localhost: The domain name that nginx should listen to. May be a string with several whitespace-separated domain names.
 - NGINX_WORKER_PROCESSES=1: The amount of worker processes nginx should spawn.
 - NGINX_WORKER_CONNECTIONS=1024: The amount of worker connections one process may have open at a given time.

nginx version: 1.11.5
mysql client version: 10.1.18

Enabled/disabled features:
 - NGINX_ENABLE_HTTPS=0: If HTTPS should be enabled.
 - NGINX_ENABLE_HTTP2=0: If HTTP 2.0 should be enabled.
 - PHP_SERVER=: The PHP server nginx should pass requests to. Defaults to "", which means it will use the current.
 - MAIL_ENABLE=0: If postfix should be enabled
 - CRON_ENABLE=0/1: Default 0.

Supported PHP variables and their defaults:
 - PHP_MAX_EXECUTION_TIME=300: How many seconds a PHP request may take before it should timeout.
 - PHP_MAX_UPLOAD_SIZE=32: How many megabytes an user is allowed to upload to the server.
 - PHP_TIMEZONE=Europe/Helsinki: The timezone that should be set

PHP version: 5.6.28

Supported postfix variables and their defaults:
 - POSTFIX_DOMAIN: Mandatory. Which domain postfix should pretend to send from.
 - POSTFIX_SMTP_SERVER: Mandatory. The smtp server postfix should forward mail to.
 - POSTFIX_SMTP_PORT=25: The port of the smtp server.
 - POSTFIX_LOGIN_EMAIL=: The email address that should be used for login to the server.
 - POSTFIX_LOGIN_PASSWORD=: The password that should be used for login to the server.
 - POSTFIX_USE_TLS=0: If tls should be used.
 - POSTFIX_USE_PLAIN_ONLY=0: Makes postfix authenticate with the server via the PLAIN method.
 - POSTFIX_FOREGROUND=1: If this script should loop endlessly after postfix is started.

postfix version: 3.1.1
```

### Filesystem layout

WWW directory: `/var/www/html`. Here you should put all your website's data and nginx will serve it.
nginx configuration directory: `/etc/nginx/conf.d`. Here you should put your website's `location` directives.
Certificates directory: `/certs`. If you enable HTTPS or HTTP2, you should volume-mount in `/certs/site.crt` as the certificate and `/certs/site.key` as the private key. Optional file for even more security is `/certs/dhparam.pem` that nginx will use if present.

### Ubuntu 16.04 cloud-init

To build the image the following [cloud-config](https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting) can be used with a Digital Ocean Ubuntu 16.04 with at least 1 GB RAM:

Remember to check the IPv6 checkbox, since GPG's dirmngr might select a v6 server from the pool and try to connect to it, even though it doesn't have v6 connectivity inside the container.

```
#cloud-config
package_update: true
packages:
  - git
  - curl
  - make
  - wget
  - nano
  - software-properties-common
  - apt-transport-https
runcmd:
  - apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys <KEY>
  - apt-add-repository -y 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
  - apt-get update -y
{'fraction_non_alphanumeric': 0.08774391021553374, 'fraction_numerical': 0.019130212983037877, 'mean_word_length': 4.010862619808306, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6900237', 'n_tokens_mistral': 2638, 'n_tokens_neox': 2436, 'n_words': 968}