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:
parent
7f4e411d3d
commit
405067d4af
26
README.md
26
README.md
@ -282,29 +282,37 @@ By default **PHP 7.0** is running.
|
||||
<br>
|
||||
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
|
||||
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/).
|
||||
|
||||
|
||||
<br>
|
||||
|
@ -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
|
||||
|
23
php/Dockerfile-php-55
Normal file
23
php/Dockerfile-php-55
Normal 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
23
php/Dockerfile-php-56
Normal 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
|
@ -1,4 +1,3 @@
|
||||
# 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
|
||||
|
||||
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
Loading…
Reference in New Issue
Block a user