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.
This commit is contained in:
Mahmoud Zalt 2016-05-14 04:50:47 +03:00
parent 7f4e411d3d
commit 405067d4af
5 changed files with 67 additions and 12 deletions

View File

@ -282,29 +282,37 @@ By default **PHP 7.0** is running.
<br> <br>
To change the default PHP version: 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.
<br>
Example to select version 5.6 instead of 7.0 you have to replace `Dockerfile-php-70` with `Dockerfile-php-56`.
Sample:
```txt ```txt
FROM php:7.0-fpm php:
build:
context: ./php
dockerfile: Dockerfile-php-70
``` ```
Supported Versions: Supported Versions:
- For (PHP 7.0.*) use `php:7.0-fpm` - For (PHP 7.0.*) use `Dockerfile-php-70`
- For (PHP 5.6.*) use `php:5.6-fpm` - For (PHP 5.6.*) use `Dockerfile-php-56`
- For (PHP 5.5.*) use `php:5.5-fpm` - 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 ```bash
docker-compose build php docker-compose build php
``` ```
For more details visit the [official PHP docker images](https://hub.docker.com/_/php/).
<br> <br>

View File

@ -18,7 +18,9 @@ services:
### PHP Container ########################################### ### PHP Container ###########################################
php: php:
build: ./php build:
context: ./php
dockerfile: Dockerfile-php-70
volumes: volumes:
- ../:/var/www/laravel - ../:/var/www/laravel
- ./logs/php/:/usr/local/var/log - ./logs/php/:/usr/local/var/log

23
php/Dockerfile-php-55 Normal file
View File

@ -0,0 +1,23 @@
FROM php:5.5-fpm
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
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

23
php/Dockerfile-php-56 Normal file
View File

@ -0,0 +1,23 @@
FROM php:5.6-fpm
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
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

View File

@ -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 <mahmoud@zalt.me> MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>