Skip to content

Commit

Permalink
add PHP-81 FPM
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamdeew committed Oct 16, 2022
1 parent 436c174 commit 3ae65a3
Show file tree
Hide file tree
Showing 12 changed files with 589 additions and 31 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@ jobs:
- name: Create site.test dir and php-file
run: mkdir -p projects/site.test && echo '<?php echo phpversion();' > projects/site.test/index.php

- name: Build the stack PHP-81 and hack with default.conf
run: cp mysql.env.example mysql.env && cp docker/nginx/config/templates/site.test.conf-php-81 docker/nginx/config/default.conf && sed -i 's/server_name site.test/server_name _/g' docker/nginx/config/default.conf && cp templates/docker-compose-php-81.yml docker-compose.yml && make upb

- name: Test DB
run: sleep 15 && docker run --network container:docker-compose-php_nginx_1 mikesplain/telnet db 3306

- name: Test acme.sh
run: docker-compose -f docker-compose.acme.yml run --rm acme acme.sh -v | grep acmesh-official
- name: Test MailHog localhost
run: docker run --network container:docker-compose-php_nginx_1 appropriate/curl -s --retry 1 --retry-connrefused http://super:demo@localhost:8025/ | grep 'MailHog'
- name: Test Adminer localhost
run: docker run --network container:docker-compose-php_nginx_1 appropriate/curl -s --retry 1 --retry-connrefused http://super:demo@localhost:8080/ | grep 'adminer.org'

- name: Test node
run: docker-compose -f docker-compose.node.yml run --rm node-10 node -v | grep 'v10'
- name: Test mycli
run: docker-compose -f docker-compose.mycli.yml run --rm mycli mycli -V | grep 'Version:'
- name: Test mysqltuner
run: docker-compose -f docker-compose.mysqltuner.yml run --rm mysqltuner /opt/mysqltuner --help | grep 'MySQLTuner'

- name: Test PHP-FPM
run: docker run --network container:docker-compose-php_nginx_1 mikesplain/telnet php-81 9000
- name: Test Nginx localhost
run: docker run --network container:docker-compose-php_nginx_1 appropriate/curl -s --retry 1 --retry-connrefused http://super:demo@localhost/ | grep '8.1'

- name: Stop containers
run: make st

- name: Build the stack PHP-8 and hack with default.conf
run: cp mysql.env.example mysql.env && cp docker/nginx/config/templates/site.test.conf-php-8 docker/nginx/config/default.conf && sed -i 's/server_name site.test/server_name _/g' docker/nginx/config/default.conf && cp templates/docker-compose-php-8.yml docker-compose.yml && make upb

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ st: stop
ps:
docker-compose ps

#make logs name=php-8
#make logs name=php-81
logs:
docker-compose logs --tail=100 -f $(name) || true
nlogs:
Expand All @@ -17,13 +17,13 @@ dblogs:
docker-compose logs --tail=100 -f db || true


#make rs name=php-8
#make rs name=php-81
rs:
docker-compose restart $(name)
nrs:
docker-compose restart nginx

#make exec name=php-8
#make exec name=php-81
exec:
docker-compose exec $(name) /bin/sh || true
ex: exec
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Nginx + MariaDB + MailHog + PHP-7.1/7.2/7.3/7.4/8.0 FPM + Apache mod-php 5.6/7.1/7.4
## Nginx + MariaDB + MailHog + PHP-7.1/7.2/7.3/7.4/8.0/8.1 FPM + Apache mod-php 5.6/7.1/7.4

![](https://github.com/rhamdeew/docker-compose-php/workflows/Docker%20Image%20CI/badge.svg)

Expand All @@ -24,7 +24,7 @@ and add

```
cp mysql.env.example mysql.env
cp docker/nginx/config/templates/site.test.conf-php-8 docker/nginx/config/site.test.conf
cp docker/nginx/config/templates/site.test.conf-php-81 docker/nginx/config/site.test.conf
mkdir -p projects/site.test
echo '<?php echo phpversion();' > projects/site.test/index.php
make up
Expand All @@ -39,11 +39,11 @@ cp mysql.env.example mysql.env
#edit mysql.env
#you can choose the template with specific php version
cp templates/docker-compose-php-8.yml docker-compose.yml
cp templates/docker-compose-php-81.yml docker-compose.yml
#and copy specific config for Nginx + PHP-FPM
cp docker/nginx/config/templates/site.test.conf-php-8 docker/nginx/config/site.test.conf
cp docker/nginx/config/templates/site.test.conf-php-81 docker/nginx/config/site.test.conf
#or copy configs for Nginx + Apache PHP
cp templates/docker-compose-apache-php-74.yml docker-compose.yml
Expand Down Expand Up @@ -100,8 +100,8 @@ make ps
#### Viewing container logs

```
#docker-compose logs -tail=100 -f (php-8|db|mailhog|nginx)
make logs name=php-8
#docker-compose logs -tail=100 -f (php-81|db|mailhog|nginx)
make logs name=php-81
```

*Database host - db*
Expand All @@ -123,7 +123,7 @@ Then uncomment the line
#RUN usermod -u 1050 www-data && groupmod -g 1050 www-data
```

In `docker/php-8/build/Dockerfile` and replace id 1050 with your identifiers there.
In `docker/php-81/build/Dockerfile` and replace id 1050 with your identifiers there.
We start containers with a rebuild

```
Expand All @@ -134,7 +134,7 @@ make upb

#### php.ini settings

Open `docker/php-8/config/php.ini`
Open `docker/php-81/config/php.ini`
Or edit the php-fpm settings - www.conf


Expand Down Expand Up @@ -189,7 +189,7 @@ make mycli

```
#docker-compose exec $(name) /bin/sh || true
make exec name=php-8
make exec name=php-81
```


Expand All @@ -206,7 +206,7 @@ Changed in mysql.env file
#### An example of running Cron background tasks

```
* * * * * /usr/local/bin/docker-compose -f /srv/www/docker-compose-php/docker-compose.yml exec php-8 /srv/projects/site.test/yii api/send
* * * * * /usr/local/bin/docker-compose -f /srv/www/docker-compose-php/docker-compose.yml exec php-81 /srv/projects/site.test/yii api/send
```

#### Acme.sh
Expand Down
20 changes: 10 additions & 10 deletions README_ru.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Nginx + MariaDB + MailHog + PHP-7.1/7.2/7.3/7.4/8.0 FPM + Apache mod-php 5.6/7.1/7.4
## Nginx + MariaDB + MailHog + PHP-7.1/7.2/7.3/7.4/8.0/8.1 FPM + Apache mod-php 5.6/7.1/7.4

![](https://github.com/rhamdeew/docker-compose-php/workflows/Docker%20Image%20CI/badge.svg)

Expand Down Expand Up @@ -29,7 +29,7 @@ sudo vim /etc/hosts

```
cp mysql.env.example mysql.env
cp docker/nginx/config/templates/site.test.conf-php-8 docker/nginx/config/site.test.conf
cp docker/nginx/config/templates/site.test.conf-php-81 docker/nginx/config/site.test.conf
mkdir -p projects/site.test
echo '<?php echo phpversion();' > projects/site.test/index.php
make up
Expand All @@ -43,11 +43,11 @@ cp mysql.env.example mysql.env
#edit mysql.env
#вы можете выбрать версию PHP
cp templates/docker-compose-php-8.yml docker-compose.yml
cp templates/docker-compose-php-81.yml docker-compose.yml
#и скопировать соответствующий конфиг для Nginx + PHP-FPM
cp docker/nginx/config/templates/site.test.conf-php-8 docker/nginx/config/site.test.conf
cp docker/nginx/config/templates/site.test.conf-php-81 docker/nginx/config/site.test.conf
#или скопировать соответствующие конфиги для варианта Nginx + Apache PHP
cp templates/docker-compose-apache-php-74.yml docker-compose.yml
Expand Down Expand Up @@ -105,8 +105,8 @@ make ps
#### Просмотр логов контейнера

```
#docker-compose logs -tail=100 -f (php-8|db|mailhog|nginx)
make logs name=php-8
#docker-compose logs -tail=100 -f (php-81|db|mailhog|nginx)
make logs name=php-81
```


Expand All @@ -127,7 +127,7 @@ make logs name=php-8
#RUN usermod -u 1050 www-data && groupmod -g 1050 www-data
```

В `docker/php-8/build/Dockerfile` и заменяем там 1050 на свои идентификаторы.
В `docker/php-81/build/Dockerfile` и заменяем там 1050 на свои идентификаторы.
Запускаем все с ребилдом

```
Expand All @@ -138,7 +138,7 @@ make upb

#### Настройки php.ini

Открываем `docker/php-8/config/php.ini`
Открываем `docker/php-81/config/php.ini`
Или же редактируем настройки php-fpm - www.conf


Expand Down Expand Up @@ -178,7 +178,7 @@ make mycli

```
#docker-compose exec $(name) /bin/sh || true
make exec name=php-8
make exec name=php-81
```


Expand All @@ -195,7 +195,7 @@ make exec name=php-8
#### Пример запуска фоновых задач по Cron

```
* * * * * /usr/local/bin/docker-compose -f /srv/www/docker-compose-php/docker-compose.yml exec php-8 /srv/projects/site.test/yii api/send
* * * * * /usr/local/bin/docker-compose -f /srv/www/docker-compose-php/docker-compose.yml exec php-81 /srv/projects/site.test/yii api/send
```

#### Acme.sh
Expand Down
14 changes: 7 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ services:
image: adminer
restart: unless-stopped

php-8:
build: ./docker/php-8/build
image: php-8
php-81:
build: ./docker/php-81/build
image: php-81
restart: unless-stopped
env_file:
- mysql.env
volumes:
- ./docker/php-8/config/msmtprc:/etc/msmtprc:ro
- ./docker/php-8/config/php.ini:/usr/local/etc/php/conf.d/my.ini:ro
- ./docker/php-8/config/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
- ./docker/php-8/composer/:/root/.composer/
- ./docker/php-81/config/msmtprc:/etc/msmtprc:ro
- ./docker/php-81/config/php.ini:/usr/local/etc/php/conf.d/my.ini:ro
- ./docker/php-81/config/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
- ./docker/php-81/composer/:/root/.composer/
- ./projects/:/srv/projects/
logging: *default-logging
3 changes: 2 additions & 1 deletion docker/nginx/config/disabled/https_site.test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ server {
location ~ \.php$ {
try_files $uri = 404;
include fastcgi_params;
fastcgi_pass php-8:9000;
fastcgi_pass php-81:9000;
# fastcgi_pass php-74:9000;
# fastcgi_pass php-73:9000;
# fastcgi_pass php-72:9000;
# fastcgi_pass php-71:9000;
# fastcgi_pass php-8:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $host;
Expand Down
35 changes: 35 additions & 0 deletions docker/nginx/config/templates/site.test.conf-php-81
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
server {
listen 80;

#имя сервера:
server_name site.test;

# корневая директория
root /srv/projects/site.test;
include conf.d/includes/restrictions.inc;

satisfy any;
allow 192.168.1.0/24;
deny all;
auth_basic "Restricted";
auth_basic_user_file .htpasswd;

######################################
# FPM config
######################################
location ~ \.php$ {
try_files $uri = 404;
include fastcgi_params;
fastcgi_pass php-81:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $host;
}

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}

include conf.d/includes/assets.inc;
}
2 changes: 2 additions & 0 deletions docker/php-81/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM rhamdeew/docker-php-81-fpm-alpine
#RUN usermod -u 1050 www-data && groupmod -g 1050 www-data
4 changes: 4 additions & 0 deletions docker/php-81/config/msmtprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
account mailhog
host mailhog
port 1025
from test@test.ru
7 changes: 7 additions & 0 deletions docker/php-81/config/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
date.timezone = "Europe/Moscow"
display_errors = On
sendmail_path = "/usr/bin/msmtp -a mailhog -t"

post_max_size = 20M
upload_max_filesize=20M

Loading

0 comments on commit 3ae65a3

Please sign in to comment.