Page MenuHomeDevCentral

No OneTemporary

diff --git a/Dockerfile b/Dockerfile
index 3f162c1..8e36022 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,97 +1,97 @@
#
# Nasqueron - Base nginx / php-fpm image
#
FROM armv7/armhf-debian
MAINTAINER Kaliiixx <modepadu95@riseup.net>
#
# Prepare the container
#
-ENV PHP_VERSION 5.6.16
+ENV PHP_VERSION 5.6.19
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=app --with-fpm-group=app
ENV PHP_INI_DIR /usr/local/etc/php
ENV PHP_BUILD_DEPS bzip2 \
file \
libbz2-dev \
libcurl4-openssl-dev \
libjpeg-dev \
libmcrypt-dev \
libpng12-dev \
libreadline6-dev \
libssl-dev \
libxslt1-dev \
libxml2-dev
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
RUN apt-get update && apt-get install -y ca-certificates curl libxml2 autoconf \
gcc libc-dev make pkg-config nginx-full \
runit nano less tmux wget git \
$PHP_BUILD_DEPS $PHP_EXTRA_BUILD_DEPS \
--no-install-recommends && rm -r /var/lib/apt/lists/*
RUN gpg --keyserver pool.sks-keyservers.net --recv-keys 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 0BD78B5F97500D450838F95DFE857D9A90D90EC1 \
&& mkdir -p $PHP_INI_DIR/conf.d \
&& set -x \
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2 \
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.bz2.asc/from/this/mirror" -o php.tar.bz2.asc \
&& gpg --verify php.tar.bz2.asc \
&& mkdir -p /usr/src/php \
&& tar -xof php.tar.bz2 -C /usr/src/php --strip-components=1 \
&& rm php.tar.bz2* \
&& cd /usr/src/php \
&& ./configure \
--with-config-file-path="$PHP_INI_DIR" \
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
--disable-cgi \
--enable-mysqlnd \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-gd \
--with-jpeg-dir \
--enable-gd-native-ttf \
--enable-mbstring \
--with-mcrypt \
--with-mysqli \
--with-pdo-mysql \
--enable-pcntl \
--with-openssl \
--with-xsl \
--with-readline \
--with-zlib \
--enable-zip \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \
&& make clean \
&& pecl install APCu-4.0.10 \
&& cd /opt \
&& curl -sS https://getcomposer.org/installer | php \
&& ln -s /opt/composer.phar /usr/local/bin/composer
RUN groupadd -r app -g 433 && \
mkdir /home/app && \
mkdir -p /var/wwwroot/default && \
useradd -u 431 -r -g app -d /home/app -s /sbin/nologin -c "Docker image user for web application" app && \
chown -R app:app /home/app /var/wwwroot/default && \
chmod 700 /home/app && \
chmod 711 /var/wwwroot/default
COPY files /
#
# Docker properties
#
VOLUME ["/var/wwwroot/default", "/etc/nginx"]
EXPOSE 80
EXPOSE 443
CMD ["/usr/local/sbin/runsvdir-init"]
diff --git a/README.md b/README.md
index fa9e410..63ccfb1 100644
--- a/README.md
+++ b/README.md
@@ -1,50 +1,63 @@
# Nginx, php-fpm and runit base image
## Description
Out of the box, this image offers a working nginx and php-fpm webserver.
This image is intended to allow to run a PHP application either passing
a PHP application folder webroot as argument, either writing a Dockerfile
with `nasqueron/nginx-php-fpm` image as base image.
Your web directory — if you don't add vhosts — is
`/var/wwwroot/default` (mounted as volume).
The PHP last 5.6 version is compiled through a build process borrowed from
the official PHP Docker image, with [this Dockerfile used](https://github.com/docker-library/php/blob/08bf31dfd492f02a2696c9a30eb85326b1570abd/5.6/fpm/Dockerfile).
We add common extensions like calendar, curl, gd, iconv, libxml, mbstring,
mcrypt, mysqli, PDO MySQL and pcntl. The Pear, PECL executables and utilities
(including build stuff like phpize) are available too.
Once running, you can quickly add PHP extensions to this image,
with `docker-php-ext-configure` and `docker-php-ext-install` scripts.
Nginx is installed through the [nginx-full Debian package](https://wiki.debian.org/Nginx).
SSL is ready if needed at the container level (we expose ports 80 and 443).
Services are managed by [runit](http://smarden.org/runit/) in `/etc/service` directory.
## How to use it
To rebuild this image:
docker build --tag nasqueron/nginx-php-fpm .
To rebuild a fork of this image based on a modified Dockerfile:
docker build --tag your-image-name-tag .
To launch a container to execute a PHP application in /data/awesome-php-app
with http://localhost:8080 as address:
docker run -d -v /data/awesome-php-app:/var/wwwroot/default -p 8080:80 nasqueron/nginx-php-fpm
To create an image for an application with thisas base, create a Dockerfile:
FROM nasqueron/docker-nginx-php-fpm
# Debian commands to deploy your application code
# If you need other processes, adds a /etc/service/<service name>/run file
That's it.
+<<<<<<< HEAD
# docker-arm-nginx-php-fpm
+=======
+
+## How to upgrade this image?
+
+As noted in https://devcentral.nasqueron.org/T787 we need to sync files and novolume/files.
+
+For that, you can use our helper Makefile:
+```
+cd novolume
+make update
+```
+>>>>>>> 4e6ef53562dafae51fbd8da1dbaf50148bbda6aa
diff --git a/Dockerfile b/novolume/Dockerfile
similarity index 94%
copy from Dockerfile
copy to novolume/Dockerfile
index 3f162c1..f3db1e9 100644
--- a/Dockerfile
+++ b/novolume/Dockerfile
@@ -1,97 +1,95 @@
#
# Nasqueron - Base nginx / php-fpm image
#
-FROM armv7/armhf-debian
-MAINTAINER Kaliiixx <modepadu95@riseup.net>
+FROM debian:jessie
+MAINTAINER Sébastien Santoro aka Dereckson <dereckson+nasqueron-docker@espace-win.org>
#
# Prepare the container
#
-ENV PHP_VERSION 5.6.16
+ENV PHP_VERSION 5.6.19
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=app --with-fpm-group=app
ENV PHP_INI_DIR /usr/local/etc/php
ENV PHP_BUILD_DEPS bzip2 \
file \
libbz2-dev \
libcurl4-openssl-dev \
libjpeg-dev \
libmcrypt-dev \
libpng12-dev \
libreadline6-dev \
libssl-dev \
libxslt1-dev \
libxml2-dev
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
RUN apt-get update && apt-get install -y ca-certificates curl libxml2 autoconf \
gcc libc-dev make pkg-config nginx-full \
runit nano less tmux wget git \
$PHP_BUILD_DEPS $PHP_EXTRA_BUILD_DEPS \
--no-install-recommends && rm -r /var/lib/apt/lists/*
RUN gpg --keyserver pool.sks-keyservers.net --recv-keys 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 0BD78B5F97500D450838F95DFE857D9A90D90EC1 \
&& mkdir -p $PHP_INI_DIR/conf.d \
&& set -x \
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2 \
&& curl -SL "http://php.net/get/php-$PHP_VERSION.tar.bz2.asc/from/this/mirror" -o php.tar.bz2.asc \
&& gpg --verify php.tar.bz2.asc \
&& mkdir -p /usr/src/php \
&& tar -xof php.tar.bz2 -C /usr/src/php --strip-components=1 \
&& rm php.tar.bz2* \
&& cd /usr/src/php \
&& ./configure \
--with-config-file-path="$PHP_INI_DIR" \
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
--disable-cgi \
--enable-mysqlnd \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-gd \
--with-jpeg-dir \
--enable-gd-native-ttf \
--enable-mbstring \
--with-mcrypt \
--with-mysqli \
--with-pdo-mysql \
--enable-pcntl \
--with-openssl \
--with-xsl \
--with-readline \
--with-zlib \
--enable-zip \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \
&& make clean \
&& pecl install APCu-4.0.10 \
&& cd /opt \
&& curl -sS https://getcomposer.org/installer | php \
&& ln -s /opt/composer.phar /usr/local/bin/composer
RUN groupadd -r app -g 433 && \
mkdir /home/app && \
mkdir -p /var/wwwroot/default && \
useradd -u 431 -r -g app -d /home/app -s /sbin/nologin -c "Docker image user for web application" app && \
chown -R app:app /home/app /var/wwwroot/default && \
chmod 700 /home/app && \
chmod 711 /var/wwwroot/default
-COPY files /
+COPY files /
#
# Docker properties
#
-VOLUME ["/var/wwwroot/default", "/etc/nginx"]
-
EXPOSE 80
EXPOSE 443
CMD ["/usr/local/sbin/runsvdir-init"]
diff --git a/novolume/Makefile b/novolume/Makefile
new file mode 100644
index 0000000..595d2f3
--- /dev/null
+++ b/novolume/Makefile
@@ -0,0 +1,9 @@
+all: files
+
+files:
+ cp -Rp ../files .
+
+clean:
+ rm -rf files
+
+update: clean files
diff --git a/novolume/files/etc/nginx/nginx.conf b/novolume/files/etc/nginx/nginx.conf
new file mode 100644
index 0000000..a60716c
--- /dev/null
+++ b/novolume/files/etc/nginx/nginx.conf
@@ -0,0 +1,43 @@
+# Webserver runs as www-data user
+# PHP code runs as app user
+# This allows to configure a read-only, can execute web directory.
+
+user www-data;
+worker_processes 4;
+pid /run/nginx.pid;
+daemon off;
+
+events {
+ worker_connections 768;
+}
+
+http {
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+ keepalive_timeout 65;
+ types_hash_max_size 2048;
+
+ client_max_body_size 32M;
+
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
+ ssl_prefer_server_ciphers on;
+
+ access_log /var/log/nginx/access.log;
+ error_log /var/log/nginx/error.log;
+
+ gzip on;
+ gzip_disable "msie6";
+ gzip_vary on;
+ gzip_proxied any;
+ gzip_comp_level 6;
+ gzip_buffers 16 8k;
+ gzip_http_version 1.1;
+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
+
+ include /etc/nginx/conf.d/*.conf;
+ include /etc/nginx/sites-enabled/*;
+}
diff --git a/novolume/files/etc/nginx/sites-available/default b/novolume/files/etc/nginx/sites-available/default
new file mode 100644
index 0000000..3d8c49e
--- /dev/null
+++ b/novolume/files/etc/nginx/sites-available/default
@@ -0,0 +1,18 @@
+server {
+ listen 80 default_server;
+ listen [::]:80 default_server;
+ server_name _;
+
+ root /var/wwwroot/default;
+
+ index index.html index.php index.htm;
+
+ location / {
+ try_files $uri $uri/ =404;
+ }
+
+ location ~ \.php$ {
+ include snippets/fastcgi-php.conf;
+ fastcgi_pass 127.0.0.1:9000;
+ }
+}
diff --git a/novolume/files/etc/service/nginx/run b/novolume/files/etc/service/nginx/run
new file mode 100755
index 0000000..384d533
--- /dev/null
+++ b/novolume/files/etc/service/nginx/run
@@ -0,0 +1,4 @@
+#!/bin/bash
+exec 2>&1
+source /usr/local/etc/envvars
+exec /usr/sbin/nginx
diff --git a/novolume/files/etc/service/php-fpm/run b/novolume/files/etc/service/php-fpm/run
new file mode 100755
index 0000000..e440441
--- /dev/null
+++ b/novolume/files/etc/service/php-fpm/run
@@ -0,0 +1,5 @@
+#!/bin/bash
+exec 2>&1
+source /usr/local/etc/envvars
+php-fpm-env > /usr/local/etc/php-fpm-env.conf
+exec /usr/local/sbin/php-fpm --nodaemonize
diff --git a/novolume/files/usr/local/bin/docker-php-ext-configure b/novolume/files/usr/local/bin/docker-php-ext-configure
new file mode 100755
index 0000000..3d21b5b
--- /dev/null
+++ b/novolume/files/usr/local/bin/docker-php-ext-configure
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+ext="$1"
+extDir="/usr/src/php/ext/$ext"
+if [ -z "$ext" -o ! -d "$extDir" ]; then
+ echo >&2 "usage: $0 ext-name [configure flags]"
+ echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
+ echo >&2
+ echo >&2 'Possible values for ext-name:'
+ echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+ exit 1
+fi
+shift
+
+set -x
+cd "$extDir"
+phpize
+./configure "$@"
diff --git a/novolume/files/usr/local/bin/docker-php-ext-install b/novolume/files/usr/local/bin/docker-php-ext-install
new file mode 100755
index 0000000..ca65449
--- /dev/null
+++ b/novolume/files/usr/local/bin/docker-php-ext-install
@@ -0,0 +1,60 @@
+#!/bin/bash
+set -e
+
+cd /usr/src/php/ext
+
+usage() {
+ echo "usage: $0 ext-name [ext-name ...]"
+ echo " ie: $0 gd mysqli"
+ echo " $0 pdo pdo_mysql"
+ echo
+ echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
+ echo
+ echo 'Possible values for ext-name:'
+ echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+}
+
+exts=()
+while [ $# -gt 0 ]; do
+ ext="$1"
+ shift
+ if [ -z "$ext" ]; then
+ continue
+ fi
+ if [ ! -d "$ext" ]; then
+ echo >&2 "error: $(pwd -P)/$ext does not exist"
+ echo >&2
+ usage >&2
+ exit 1
+ fi
+ exts+=( "$ext" )
+done
+
+if [ "${#exts[@]}" -eq 0 ]; then
+ usage >&2
+ exit 1
+fi
+
+for ext in "${exts[@]}"; do
+ (
+ cd "$ext"
+ [ -e Makefile ] || docker-php-ext-configure "$ext"
+ make
+ make install
+ ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
+ for module in modules/*.so; do
+ if [ -f "$module" ]; then
+ if grep -q zend_extension_entry "$module"; then
+ # https://wiki.php.net/internals/extensions#loading_zend_extensions
+ line="zend_extension=$(basename "$module")"
+ else
+ line="extension=$(basename "$module")"
+ fi
+ if ! grep -q "$line" "$ini"; then
+ echo "$line" >> "/usr/local/etc/php/conf.d/ext-$ext.ini"
+ fi
+ fi
+ done
+ make clean
+ )
+done
diff --git a/novolume/files/usr/local/etc/php-fpm.conf b/novolume/files/usr/local/etc/php-fpm.conf
new file mode 100644
index 0000000..149df8c
--- /dev/null
+++ b/novolume/files/usr/local/etc/php-fpm.conf
@@ -0,0 +1,13 @@
+[app]
+listen = 127.0.0.1:9000
+user = app
+group = app
+pm = ondemand
+pm.max_children = 10
+pm.process_idle_timeout = 60
+pm.max_requests = 500
+
+php_admin_flag[cgi.fix_pathinfo] = off
+
+include=etc/php-fpm-env.conf
+
diff --git a/novolume/files/usr/local/etc/php/conf.d/apcu.ini b/novolume/files/usr/local/etc/php/conf.d/apcu.ini
new file mode 100644
index 0000000..231a43c
--- /dev/null
+++ b/novolume/files/usr/local/etc/php/conf.d/apcu.ini
@@ -0,0 +1 @@
+extension=apcu.so
diff --git a/novolume/files/usr/local/etc/php/conf.d/date.ini b/novolume/files/usr/local/etc/php/conf.d/date.ini
new file mode 100644
index 0000000..7a16d79
--- /dev/null
+++ b/novolume/files/usr/local/etc/php/conf.d/date.ini
@@ -0,0 +1,4 @@
+[date]
+date.timezone = UTC
+date.default_latitude = 50.37
+date.default_longitude = 4.49
diff --git a/novolume/files/usr/local/etc/php/conf.d/opcache.ini b/novolume/files/usr/local/etc/php/conf.d/opcache.ini
new file mode 100644
index 0000000..f5ebae0
--- /dev/null
+++ b/novolume/files/usr/local/etc/php/conf.d/opcache.ini
@@ -0,0 +1,3 @@
+zend_extension=opcache.so
+opcache.enable=On
+opcache.validate_timestamps=0
diff --git a/novolume/files/usr/local/lib/php-fpm-env/PhpFpmEnvironment.php b/novolume/files/usr/local/lib/php-fpm-env/PhpFpmEnvironment.php
new file mode 100755
index 0000000..61788c5
--- /dev/null
+++ b/novolume/files/usr/local/lib/php-fpm-env/PhpFpmEnvironment.php
@@ -0,0 +1,103 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * Allows to get the content of a php-fpm environment configuration file
+ */
+class PhpFpmEnvironment {
+ /**
+ * The temporary directory, used in TMP, TEMP and TMPDIR environment variables
+ * @var string
+ */
+ const TMP = '/tmp';
+
+ /**
+ * The path where to find executables, where sbin should be excluded if you don't run PHP as root.
+ * @var string
+ */
+ const PATH = '/usr/local/bin:/usr/bin:/bin';
+
+ /**
+ * The environment variables to discard
+ * @var Array
+ */
+ const VARIABLES_TO_DISCARD = [
+ '_', // The caller executable script, not pertinent
+ 'HOME', // Set correctly by php-fpm
+ 'TERM', // Not pertinent in server context
+ 'MYSQL_ENV_MYSQL_ROOT_PASSWORD', // from --link …:mysql
+ ];
+
+ /**
+ * Gets an environment array from the current process environment,
+ * with PATH and temp variablesfiltered.
+ *
+ * @return Array
+ */
+ public static function getEnvironmentVariables () {
+ $variables = [];
+
+ foreach ($_ENV as $key => $value) {
+ if (!static::mustIgnoreVariable($key)) {
+ $variables[$key] = $value;
+ }
+ }
+
+ static::addHardcodedEnvironmentVariables($variables);
+
+ return $variables;
+ }
+
+ /**
+ * Adds hardcoded and always wanted environment variables
+ * (path, temporary directory) to the specified array.
+ *
+ * @paran array $variables the array to add the variables to
+ */
+ public static function addHardcodedEnvironmentVariables (&$variables) {
+ static::addTempEnvironmentVariables ($variables);
+ static::addPathEnvironmentVariables ($variables);
+ }
+
+ /**
+ * Adds temporary directory environment variables to the specified array.
+ *
+ * @paran array $variables the array to add the variables to
+ */
+ public static function addTempEnvironmentVariables (&$variables) {
+ $variables['TMP'] = static::TMP;
+ $variables['TEMP'] = static::TMP;
+ $variables['TMPDIR'] = static::TMP;
+ }
+
+ /**
+ * Adds temporary directory environment variables to the specified array.
+ *
+ * @paran array $variables the array to add the variables to
+ */
+ public static function addPathEnvironmentVariables (&$variables) {
+ $variables['PATH'] = static::PATH;
+ }
+
+ /**
+ * Determines if the variable name must be ignored
+ *
+ * @return bool true if the variable must be ignored; otherwise, false.
+ */
+ public static function mustIgnoreVariable ($variableName) {
+ return in_array($variableName, static::VARIABLES_TO_DISCARD);
+ }
+
+ /**
+ * Prints the environment
+ */
+ public static function printConfig () {
+ $variables = static::getEnvironmentVariables();
+
+ foreach ($variables as $key => $value) {
+ echo 'env["', $key, '"] = "', $value, '"', PHP_EOL;
+ }
+ }
+}
+
+PhpFpmEnvironment::printConfig();
diff --git a/novolume/files/usr/local/sbin/php-fpm-env b/novolume/files/usr/local/sbin/php-fpm-env
new file mode 120000
index 0000000..09e4c0b
--- /dev/null
+++ b/novolume/files/usr/local/sbin/php-fpm-env
@@ -0,0 +1 @@
+../lib/php-fpm-env/PhpFpmEnvironment.php
\ No newline at end of file
diff --git a/novolume/files/usr/local/sbin/runsvdir-init b/novolume/files/usr/local/sbin/runsvdir-init
new file mode 100755
index 0000000..7c16fd2
--- /dev/null
+++ b/novolume/files/usr/local/sbin/runsvdir-init
@@ -0,0 +1,3 @@
+#!/bin/bash
+export > /usr/local/etc/envvars
+exec /usr/sbin/runsvdir-start

File Metadata

Mime Type
text/x-diff
Expires
Fri, Sep 19, 00:20 (22 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2991952
Default Alt Text
(18 KB)

Event Timeline