From 405067d4afaf8d0c62ced33d3716ba98cd101ed0 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Sat, 14 May 2016 04:50:47 +0300 Subject: [PATCH] Separate the PHP versions to multiple dockerfiles Because there's some difference in installing some libraries between PHP 5 and PHP 7. There must be multiple php dockerfiles. For that I created 3 docker files each of a different version, this will make it easy for the users to switch between the PHP version by just editing the docker-compose file and not touching the dockerfiles. --- README.md | 26 +++++++++++++++++--------- docker-compose.yml | 4 +++- php/Dockerfile-php-55 | 23 +++++++++++++++++++++++ php/Dockerfile-php-56 | 23 +++++++++++++++++++++++ php/{Dockerfile => Dockerfile-php-70} | 3 +-- 5 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 php/Dockerfile-php-55 create mode 100644 php/Dockerfile-php-56 rename php/{Dockerfile => Dockerfile-php-70} (84%) diff --git a/README.md b/README.md index 358beee3..c8c4e620 100644 --- a/README.md +++ b/README.md @@ -282,29 +282,37 @@ By default **PHP 7.0** is running.
To change the default PHP version: -1 - Open the `dockerfile` of the `php` folder. +1 - Open the `docker-compose.yml`. -2 - Change the PHP version number in the first line, +2 - Search for `Dockerfile-php-70` in the PHP container section. + +3 - Change the version number. +
+Example to select version 5.6 instead of 7.0 you have to replace `Dockerfile-php-70` with `Dockerfile-php-56`. + +Sample: ```txt -FROM php:7.0-fpm +php: + build: + context: ./php + dockerfile: Dockerfile-php-70 ``` Supported Versions: -- For (PHP 7.0.*) use `php:7.0-fpm` -- For (PHP 5.6.*) use `php:5.6-fpm` -- For (PHP 5.5.*) use `php:5.5-fpm` +- For (PHP 7.0.*) use `Dockerfile-php-70` +- For (PHP 5.6.*) use `Dockerfile-php-56` +- For (PHP 5.5.*) use `Dockerfile-php-55` -For more details visit the [official PHP docker images](https://hub.docker.com/_/php/). -3 - Finally rebuild the container +4 - Finally rebuild the container ```bash docker-compose build php ``` - +For more details visit the [official PHP docker images](https://hub.docker.com/_/php/).
diff --git a/docker-compose.yml b/docker-compose.yml index af36bcef..549458d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,9 @@ services: ### PHP Container ########################################### php: - build: ./php + build: + context: ./php + dockerfile: Dockerfile-php-70 volumes: - ../:/var/www/laravel - ./logs/php/:/usr/local/var/log diff --git a/php/Dockerfile-php-55 b/php/Dockerfile-php-55 new file mode 100644 index 00000000..b8f69b2d --- /dev/null +++ b/php/Dockerfile-php-55 @@ -0,0 +1,23 @@ +FROM php:5.5-fpm + +MAINTAINER Mahmoud Zalt + +ADD ./laravel.ini /usr/local/etc/php/conf.d +ADD ./laravel.pool.conf /usr/local/etc/php-fpm.d/ + +RUN apt-get update && apt-get install \ + libpq-dev -y \ + curl + +# Install extensions using the helper script provided by the base image +RUN docker-php-ext-install \ + pdo_mysql \ + pdo_pgsql + +RUN usermod -u 1000 www-data + +WORKDIR /var/www/laravel + +CMD ["php-fpm"] + +EXPOSE 9000 diff --git a/php/Dockerfile-php-56 b/php/Dockerfile-php-56 new file mode 100644 index 00000000..b43fe415 --- /dev/null +++ b/php/Dockerfile-php-56 @@ -0,0 +1,23 @@ +FROM php:5.6-fpm + +MAINTAINER Mahmoud Zalt + +ADD ./laravel.ini /usr/local/etc/php/conf.d +ADD ./laravel.pool.conf /usr/local/etc/php-fpm.d/ + +RUN apt-get update && apt-get install \ + libpq-dev -y \ + curl + +# Install extensions using the helper script provided by the base image +RUN docker-php-ext-install \ + pdo_mysql \ + pdo_pgsql + +RUN usermod -u 1000 www-data + +WORKDIR /var/www/laravel + +CMD ["php-fpm"] + +EXPOSE 9000 diff --git a/php/Dockerfile b/php/Dockerfile-php-70 similarity index 84% rename from php/Dockerfile rename to php/Dockerfile-php-70 index 0f9635c8..e6b34160 100644 --- a/php/Dockerfile +++ b/php/Dockerfile-php-70 @@ -1,5 +1,4 @@ -# You can change the PHP version from here. After changing the PHP version, check the Memcached section below because it replies on PHP 7. -FROM php:7.0-fpm +FROM php:7.0-fpm MAINTAINER Mahmoud Zalt