Update PHP container

This commit is contained in:
Michael RICOIS 2018-03-22 15:28:21 +01:00
parent 5f513293dc
commit a424826376
10 changed files with 158 additions and 90 deletions

View File

@ -1,47 +1,53 @@
version: '2.1' version: '3'
services: services:
# PHP 7.0 FPM # PHP 5.6 FPM
dev-fpm70: fpm56:
container_name: dev-fpm70 build: ./dockerfiles/php-fpm/5.6/debian-8
image: envdev/php-fpm:7.0-debian image: php-fpm:5.6-debian
container_name: fpm56
volumes: volumes:
- /path/to/workspace:/home/vhosts - /home/antadis/workspace:/home/vhosts
links: links:
- "dev-db:db" - "db:db"
- "dev-redis:redis" - "mailcatcher:mailcatcher"
- "dev-mailcatcher:mailcatcher"
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
max-size: "1g" max-size: "1g"
max-file: "10" max-file: "10"
environment: # PHP 7.0 FPM
LOCAL_USER_ID: 1000 fpm70:
# MailCatcher build: ./dockerfiles/php-fpm/7.0/debian-9
dev-mailcatcher: image: php-fpm:7.0-debian
container_name: dev-mailcatcher container_name: fpm70
image: envdev/mailcatcher:0.6.5 volumes:
- /home/antadis/workspace:/home/vhosts
links:
- "db:db"
- "mailcatcher:mailcatcher"
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
max-size: "1g" max-size: "1g"
max-file: "10" max-file: "10"
# MailCatcher # MailCatcher
dev-redis: mailcatcher:
container_name: dev-redis build: ./dockerfiles/mailcatcher
image: envdev/redis:4.0 image: mailcatcher:0.6.5
container_name: mailcatcher
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
max-size: "1g" max-size: "1g"
max-file: "10" max-file: "10"
# MariaDB # MariaDB
dev-db: db:
container_name: dev-db build: ./dockerfiles/mariadb/10.2/debian
image: envdev/mariadb:10.2-debian image: mariadb:10.2-debian
container_name: db
user: mysql user: mysql
volumes: volumes:
- /path/to/workspace/database:/var/lib/mysql - /home/antadis/workspace/database:/var/lib/mysql
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
@ -50,20 +56,21 @@ services:
environment: environment:
MARIADB_PASS: password MARIADB_PASS: password
# Apache HTTPd # Apache HTTPd
dev-httpd: httpd:
container_name: dev-httpd build: ./dockerfiles/httpd/2.4/debian-9
image: envdev/httpd:2.4-debian image: httpd:2.4-debian
container_name: httpd
volumes: volumes:
- /path/to/workspace:/home/vhosts - /home/antadis/workspace:/home/vhosts
links: links:
- "dev-fpm70:fpm70" - "fpm56:fpm56"
- "fpm70:fpm70"
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
max-size: "1g" max-size: "1g"
max-file: "10" max-file: "10"
networks: networks:
default:
front: front:
ipv4_address: 172.10.0.2 ipv4_address: 172.10.0.2

View File

@ -1,24 +0,0 @@
FROM ubuntu:14.04
ENV TERM xterm
ENV DEBIAN_FRONTEND noninteractive
# Installation
RUN apt-get update && apt-get -y install software-properties-common nano && \
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db && \
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.1/ubuntu trusty main' && \
apt-get update && apt-get -y upgrade && apt-get -y install mariadb-client-10.1 pwgen \
php5-cli php5-mcrypt php5-apcu php5-curl php5-xmlrpc php5-xsl php5-mysqlnd php5-gd \
php5-json php5-intl php5-imagick && \
sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/cli/php.ini && \
sed -i -e 's/;mbstring.internal_encoding = UTF-8/mbstring.internal_encoding = UTF-8/g' /etc/php5/cli/php.ini && \
sed -i -e 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php5/cli/php.ini && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
# Add cron file description
# Add VOLUMEs
VOLUME ["/home/vhosts"]
CMD ["cron", "-f"]

View File

@ -1,34 +0,0 @@
FROM ubuntu:14.04
ENV TERM xterm
ENV DEBIAN_FRONTEND noninteractive
# Installation
RUN apt-get update && apt-get -y install software-properties-common nano && \
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db && \
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.1/ubuntu trusty main' && \
apt-get update && apt-get -y upgrade && apt-get -y install mariadb-client-10.1 pwgen \
php5-fpm php5-mcrypt php5-curl php5-xmlrpc php5-xsl php5-mysqlnd php5-gd \
php5-json php5-intl php5-imagick php5-apcu php-mbstring php5-redis && \
sed -i -e 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/;realpath_cache_size = 16k/realpath_cache_size = 1M/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/;mbstring.internal_encoding = UTF-8/mbstring.internal_encoding = UTF-8/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/session.save_handler = files/session.save_handler = redis/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/;session.save_path = "\/var\/lib\/php5"/session.save_path = "$REDIS_PORT_6379_TCP"/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/listen =[.]*$/listen = 9000/g' /etc/php5/fpm/pool.d/www.conf && \
touch /var/log/php5-fpm.log && chown www-data /var/log/php5-fpm.log && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
# Add VOLUMEs
VOLUME ["/home/vhosts"]
EXPOSE 9000
CMD ["php5-fpm", "-F"]

View File

@ -10,8 +10,7 @@ RUN apt-get update && apt-get -y install software-properties-common procps nano
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db && \ apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db && \
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.2/debian jessie main' && \ add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.2/debian jessie main' && \
apt-get update && apt-get -y upgrade && apt-get -y install mariadb-client-10.2 pwgen \ apt-get update && apt-get -y upgrade && apt-get -y install mariadb-client-10.2 pwgen \
php5-fpm php5-mcrypt php5-mbstring php5-curl php5-xmlrpc php5-xsl php5-mysqlnd php5-gd \ php5-fpm php5-mcrypt php5-curl php5-xmlrpc php5-xsl php5-mysqlnd php5-gd php5-json php5-intl php5-imagick php5-apcu && \
php5-json php5-intl php5-imagick php5-apcu && \
sed -i -e 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php5/fpm/php.ini && \ sed -i -e 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/fpm/php.ini && \ sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/;realpath_cache_size = 16k/realpath_cache_size = 1M/g' /etc/php5/fpm/php.ini && \ sed -i -e 's/;realpath_cache_size = 16k/realpath_cache_size = 1M/g' /etc/php5/fpm/php.ini && \
@ -21,14 +20,26 @@ RUN apt-get update && apt-get -y install software-properties-common procps nano
sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php5/fpm/php.ini && \ sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php5/fpm/php.ini && \ sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php5/fpm/php.ini && \
sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php5/fpm/php.ini && \ sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php5/fpm/php.ini && \
sed -i -e "s/;opcache.memory_consumption=64/opcache.memory_consumption=128/g" /etc/php5/fpm/php.ini && \
sed -i -e "s/;opcache.max_accelerated_files=2000/opcache.max_accelerated_files=10000/g" /etc/php5/fpm/php.ini && \
sed -i -e 's/^listen =.*/listen = 9000/g' /etc/php5/fpm/pool.d/www.conf && \ sed -i -e 's/^listen =.*/listen = 9000/g' /etc/php5/fpm/pool.d/www.conf && \
sed -i -e 's/^user = www-data/user = fpm/g' /etc/php5/fpm/pool.d/www.conf && \
sed -i -e 's/^group = www-data/group = fpm/g' /etc/php5/fpm/pool.d/www.conf && \
touch /var/log/php5-fpm.log && chown www-data /var/log/php5-fpm.log && \ touch /var/log/php5-fpm.log && chown www-data /var/log/php5-fpm.log && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \ apt-get clean && rm -rf /var/lib/apt/lists/* && \
echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
COPY composer-install.sh /
COPY entrypoint.sh /
RUN chmod +x /composer-install.sh
RUN chmod +x /entrypoint.sh
# Add VOLUMEs # Add VOLUMEs
VOLUME ["/home/vhosts"] VOLUME ["/home/vhosts"]
ENTRYPOINT ["/entrypoint.sh"]
# Expose and Run # Expose and Run
EXPOSE 9000 EXPOSE 9000
CMD ["php5-fpm", "-F"] CMD ["php5-fpm", "-F"]

View File

@ -0,0 +1,17 @@
#!/usr/bin/env sh
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --filename=composer --install-dir=/usr/local/bin --quiet
RESULT=$?
rm composer-setup.php
exit $RESULT

View File

@ -0,0 +1,12 @@
#!/bin/bash
# Add local user
# Either use the LOCAL_USER_ID if passed in at runtime or
# fallback
USER_ID=${LOCAL_USER_ID:-9001}
echo "FPM USER ID : $USER_ID"
useradd --shell /bin/bash -u $USER_ID -o -c "" -m fpm
exec "$@"

View File

@ -0,0 +1,47 @@
FROM debian:9
# Environment
ENV TERM xterm
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Europe/Paris
# Installation
RUN apt-get update && apt-get -y install software-properties-common apt-transport-https lsb-release ca-certificates curl procps gnupg nano wget git && \
curl https://packages.sury.org/php/apt.gpg | apt-key add - && echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list && \
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8 && \
add-apt-repository 'deb [arch=amd64] http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.2/debian stretch main' && \
apt-get update && apt-get -y upgrade && apt-get -y install mariadb-client-10.2 pwgen \
php5.6-fpm php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-xmlrpc php5.6-xsl php5.6-mysql php5.6-json php5.6-intl \
php5.6-zip php5.6-gd php-apcu && \
sed -i -e 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/;realpath_cache_size = 16k/realpath_cache_size = 1M/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/;mbstring.internal_encoding = UTF-8/mbstring.internal_encoding = UTF-8/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php/5.6/fpm/php.ini && \
sed -i -e "s/;opcache.memory_consumption=64/opcache.memory_consumption=128/g" /etc/php/5.6/fpm/php.ini && \
sed -i -e "s/;opcache.max_accelerated_files=2000/opcache.max_accelerated_files=10000/g" /etc/php/5.6/fpm/php.ini && \
sed -i -e 's/^listen =.*/listen = 9000/g' /etc/php/5.6/fpm/pool.d/www.conf && \
sed -i -e 's/^user = www-data/user = fpm/g' /etc/php/5.6/fpm/pool.d/www.conf && \
sed -i -e 's/^group = www-data/group = fpm/g' /etc/php/5.6/fpm/pool.d/www.conf && \
touch /var/log/php5.6-fpm.log && mkdir /run/php && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
COPY composer-install.sh /
COPY entrypoint.sh /
RUN chmod +x /composer-install.sh
RUN chmod +x /entrypoint.sh
# Add VOLUMEs
VOLUME ["/home/vhosts"]
ENTRYPOINT ["/entrypoint.sh"]
# Expose and Run
EXPOSE 9000
CMD ["php-fpm7.0", "-F"]

View File

@ -0,0 +1,17 @@
#!/usr/bin/env sh
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --filename=composer --install-dir=/usr/local/bin --quiet
RESULT=$?
rm composer-setup.php
exit $RESULT

View File

@ -0,0 +1,12 @@
#!/bin/bash
# Add local user
# Either use the LOCAL_USER_ID if passed in at runtime or
# fallback
USER_ID=${LOCAL_USER_ID:-9001}
echo "FPM USER ID : $USER_ID"
useradd --shell /bin/bash -u $USER_ID -o -c "" -m fpm
exec "$@"

View File

@ -21,6 +21,9 @@ RUN apt-get update && apt-get -y install software-properties-common procps gnupg
sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php/7.0/fpm/php.ini && \ sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php/7.0/fpm/php.ini && \
sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php/7.0/fpm/php.ini && \ sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php/7.0/fpm/php.ini && \
sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php/7.0/fpm/php.ini && \ sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php/7.0/fpm/php.ini && \
sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php/7.0/fpm/php.ini && \
sed -i -e "s/;opcache.memory_consumption=64/opcache.memory_consumption=128/g" /etc/php/7.0/fpm/php.ini && \
sed -i -e "s/;opcache.max_accelerated_files=2000/opcache.max_accelerated_files=10000/g" /etc/php/7.0/fpm/php.ini && \
sed -i -e 's/^listen =.*/listen = 9000/g' /etc/php/7.0/fpm/pool.d/www.conf && \ sed -i -e 's/^listen =.*/listen = 9000/g' /etc/php/7.0/fpm/pool.d/www.conf && \
sed -i -e 's/^user = www-data/user = fpm/g' /etc/php/7.0/fpm/pool.d/www.conf && \ sed -i -e 's/^user = www-data/user = fpm/g' /etc/php/7.0/fpm/pool.d/www.conf && \
sed -i -e 's/^group = www-data/group = fpm/g' /etc/php/7.0/fpm/pool.d/www.conf && \ sed -i -e 's/^group = www-data/group = fpm/g' /etc/php/7.0/fpm/pool.d/www.conf && \