Skip to content

Commit 3ae15aa

Browse files
author
Bryan Latten
committed
Merge pull request #51 from bryanlatten/new-parent
Dockerfile: using behance-nginx as parent
2 parents 4532f45 + 3b24c20 commit 3ae15aa

File tree

6 files changed

+76
-123
lines changed

6 files changed

+76
-123
lines changed

Dockerfile

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,21 @@
1-
FROM ubuntu:14.04.2
1+
FROM behance/docker-nginx:1.0.0
22
MAINTAINER Bryan Latten <latten@adobe.com>
33

4-
# Define the location where downstream app should live, with a child public folder
5-
ENV HTTP_WEBROOT /app/public
6-
7-
# Install pre-reqs, security updates
8-
RUN apt-get update && \
9-
apt-get -yq install \
10-
openssl=1.0.1f-1ubuntu2.15 \
11-
ca-certificates=20141019ubuntu0.14.04.1 \
12-
wget
13-
14-
# Ensure package list is up to date, add tool for PPA in the next step
15-
RUN apt-get update && \
16-
apt-get install software-properties-common=0.92.37.3 -y
17-
18-
# Install latest git with security updates
19-
# http://article.gmane.org/gmane.linux.kernel/1853266
20-
RUN add-apt-repository ppa:git-core/ppa -y && \
21-
apt-get update -yq && \
22-
apt-get install -yq git
23-
244
# Install singularity_runner
255
RUN apt-get install build-essential ruby1.9.1-dev -y && \
266
gem install --no-rdoc --no-ri singularity_dsl --version 1.6.3
277

28-
29-
# Install latest nginx-stable
30-
RUN add-apt-repository ppa:nginx/stable -y && \
8+
RUN locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \
9+
add-apt-repository ppa:git-core/ppa -y && \
10+
add-apt-repository ppa:ondrej/php5-5.6 -y && \
3111
apt-get update -yq && \
32-
apt-get install -yq nginx=1.8.0-1+trusty1
33-
34-
# IMPORTANT: PPA has UTF-8 characters in it that will fail unless locale is generated
35-
RUN locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && add-apt-repository ppa:ondrej/php5-5.6 -y
12+
apt-get install -yq git
3613

3714
# Update package cache with new PPA, install language and modules
3815
RUN apt-get update && \
3916
apt-get -yq install \
40-
php5=5.6.11+dfsg-1+deb.sury.org~trusty+1 \
41-
php5-fpm=5.6.11+dfsg-1+deb.sury.org~trusty+1 \
17+
php5=5.6.12+dfsg-1+deb.sury.org~trusty+1 \
18+
php5-fpm=5.6.12+dfsg-1+deb.sury.org~trusty+1 \
4219
php5-gearman=1.1.2-1+deb.sury.org~trusty+2 \
4320
php5-memcache=3.0.8-5+deb.sury.org~trusty+1 \
4421
php5-memcached=2.2.0-2+deb.sury.org~trusty+1 \
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# As part of the "Two Phase" build, the first phase typically runs with composer keys mounted,
4+
# allowing the dependencies to be installed, the result of which is committed
5+
6+
if [[ -f /root/.composer/config.json ]]
7+
then
8+
echo "[composer] installing app dependencies"
9+
composer install
10+
exit 99 # Signals for container to stop
11+
fi

container/root/run.d/02-env.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Adds docker environment variables where entering them as PHP-FPM environment variables
4+
VARS=`env | grep ^CFG_`;
5+
DEST_CONF=/etc/php5/fpm/pool.d/www.conf
6+
7+
echo '[env] importing environment variables (prefixed by CFG_)'
8+
for p in $VARS
9+
do
10+
ENV='env['${p/=/] = \"}\"
11+
echo $ENV >> $DEST_CONF
12+
done

container/root/run.d/03-debug.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if [[ $CFG_APP_DEBUG = 1 || $CFG_APP_DEBUG = '1' || $CFG_APP_DEBUG = 'true' ]]
4+
then
5+
6+
FASTCGI_PARAM_FILE=/etc/nginx/fastcgi_params
7+
echo '[debug] increasing fastcgi buffer size for debug headers'
8+
echo "" >> $FASTCGI_PARAM_FILE
9+
echo "# Debug Buffer Sizes" >> $FASTCGI_PARAM_FILE
10+
echo "fastcgi_buffer_size 16k;" >> $FASTCGI_PARAM_FILE
11+
echo "fastcgi_buffers 4 16k;" >> $FASTCGI_PARAM_FILE
12+
13+
echo '[debug] opcache disabled'
14+
php5dismod opcache
15+
16+
else
17+
echo '[debug] Opcache set to PERFORMANCE, NOT watching for file changes'
18+
echo 'opcache.revalidate_freq=0' >> /etc/php5/mods-available/opcache.ini
19+
echo 'opcache.validate_timestamps=0' >> /etc/php5/mods-available/opcache.ini
20+
fi

container/root/run.d/99-phpfpm.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
PHPFPM_CONF=/etc/php5/fpm/pool.d/www.conf
4+
5+
echo '[php-fpm] setting sensible PHP defaults'
6+
php5enmod defaults
7+
8+
# Baseline "optimizations" before ApacheBench succeeded at concurrency of 150
9+
# TODO: base on current memory capacity + CPU cores
10+
sed -i "s/pm.max_children = [0-9]\+/pm.max_children = 48/" $PHPFPM_CONF
11+
sed -i "s/pm.start_servers = [0-9]\+/pm.start_servers = 16/" $PHPFPM_CONF
12+
sed -i "s/pm.min_spare_servers = [0-9]\+/pm.min_spare_servers = 4/" $PHPFPM_CONF
13+
sed -i "s/pm.max_spare_servers = [0-9]\+/pm.max_spare_servers = 32/" $PHPFPM_CONF
14+
15+
# php5-fpm processes must pick up stdout/stderr from workers, will cause minor performance decrease (but is required)
16+
sed -i "s/;catch_workers_output/catch_workers_output/" $PHPFPM_CONF
17+
18+
19+
# 1. runs php5-fpm as foreground (-F)
20+
# 2. forcing php5-fpm to log to stderr even if a non-terminal is attached (-O)
21+
# 3. redirect stderr to stdout
22+
# 4. filtering the garbage string that PHP-FPM for no-reason-at-all decided to wrap the message in,
23+
# 5. reconnecting the stdout to current stdout
24+
# 6. backgrounding that process
25+
echo '[php-fpm] starting (background)'
26+
php5-fpm -F -O 2>&1 | sed -u 's,.*: \"\(.*\)$,\1,'| sed -u 's,"$,,' 1>&1 &

container/root/run.sh

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)