From 0aa3147cbb0ee8fed4b1b9d5e2a0a2c98db9c250 Mon Sep 17 00:00:00 2001 From: Constantine Karnaukhov Date: Sat, 29 Jun 2019 21:36:36 +0400 Subject: [PATCH] feat(presets): add single-entrypoint preset, reuse it from laravel and wordpress presets --- docs/presets.md | 10 ++++++++++ .../bin/10-select-single-entrypoint-preset.sh | 3 +++ .../bin/{install-bcmath => 20-install-bcmath} | 0 .../single-entrypoint/bin/10-custom-entrypoint.sh | 5 +++++ .../nginx/vhost.common.d/10-location-root.conf | 0 .../bin/10-select-single-entrypoint-preset.sh | 3 +++ .../bin/{install-wp-cli => 20-install-wp-cli} | 0 .../nginx/vhost.common.d/10-location-root.conf | 3 --- test/single-entrypoint/docker-compose.yml | 12 ++++++++++++ 9 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 spaceonfire/presets/laravel/bin/10-select-single-entrypoint-preset.sh rename spaceonfire/presets/laravel/bin/{install-bcmath => 20-install-bcmath} (100%) mode change 100755 => 100644 create mode 100644 spaceonfire/presets/single-entrypoint/bin/10-custom-entrypoint.sh rename spaceonfire/presets/{laravel => single-entrypoint}/nginx/vhost.common.d/10-location-root.conf (100%) create mode 100644 spaceonfire/presets/wordpress/bin/10-select-single-entrypoint-preset.sh rename spaceonfire/presets/wordpress/bin/{install-wp-cli => 20-install-wp-cli} (100%) delete mode 100644 spaceonfire/presets/wordpress/nginx/vhost.common.d/10-location-root.conf create mode 100644 test/single-entrypoint/docker-compose.yml diff --git a/docs/presets.md b/docs/presets.md index fe12711..586f912 100644 --- a/docs/presets.md +++ b/docs/presets.md @@ -15,6 +15,16 @@ - запрет прямого доступа из браузера к скрытым файлам, конфигам и пакетам composer, скриптам выполняющимся перед запуском веб-сервера +## Single Entrypoint + +Данный пресет направляет все запросы на `index.php` для работы динамических страниц. +Используется пресетами WordPress и Laravel. +Для использования данного пресета передайте в контейнера переменную окружения `SOF_PRESET=single-entrypoint`. + +Чтобы передать обработку запросов другому скрипту укажите его имя в переменной окружения +`ENTRYPOINT_SCRIPT`, например `ENTRYPOINT_SCRIPT=router.php`. Скрипт должен находится в WEBROOT +или поддиректории и не должен начинаться со слеша `/`. + ## WordPress Данный пресет направляет все запросы на `index.php` для работы динамических страниц, diff --git a/spaceonfire/presets/laravel/bin/10-select-single-entrypoint-preset.sh b/spaceonfire/presets/laravel/bin/10-select-single-entrypoint-preset.sh new file mode 100644 index 0000000..59dd8e3 --- /dev/null +++ b/spaceonfire/presets/laravel/bin/10-select-single-entrypoint-preset.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +select-preset single-entrypoint diff --git a/spaceonfire/presets/laravel/bin/install-bcmath b/spaceonfire/presets/laravel/bin/20-install-bcmath old mode 100755 new mode 100644 similarity index 100% rename from spaceonfire/presets/laravel/bin/install-bcmath rename to spaceonfire/presets/laravel/bin/20-install-bcmath diff --git a/spaceonfire/presets/single-entrypoint/bin/10-custom-entrypoint.sh b/spaceonfire/presets/single-entrypoint/bin/10-custom-entrypoint.sh new file mode 100644 index 0000000..c153115 --- /dev/null +++ b/spaceonfire/presets/single-entrypoint/bin/10-custom-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ ! -z "$ENTRYPOINT_SCRIPT" ]; then + sed -i "s#index.php#${ENTRYPOINT_SCRIPT}#g" /etc/nginx/vhost.common.d/10-location-root.conf +fi diff --git a/spaceonfire/presets/laravel/nginx/vhost.common.d/10-location-root.conf b/spaceonfire/presets/single-entrypoint/nginx/vhost.common.d/10-location-root.conf similarity index 100% rename from spaceonfire/presets/laravel/nginx/vhost.common.d/10-location-root.conf rename to spaceonfire/presets/single-entrypoint/nginx/vhost.common.d/10-location-root.conf diff --git a/spaceonfire/presets/wordpress/bin/10-select-single-entrypoint-preset.sh b/spaceonfire/presets/wordpress/bin/10-select-single-entrypoint-preset.sh new file mode 100644 index 0000000..59dd8e3 --- /dev/null +++ b/spaceonfire/presets/wordpress/bin/10-select-single-entrypoint-preset.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +select-preset single-entrypoint diff --git a/spaceonfire/presets/wordpress/bin/install-wp-cli b/spaceonfire/presets/wordpress/bin/20-install-wp-cli similarity index 100% rename from spaceonfire/presets/wordpress/bin/install-wp-cli rename to spaceonfire/presets/wordpress/bin/20-install-wp-cli diff --git a/spaceonfire/presets/wordpress/nginx/vhost.common.d/10-location-root.conf b/spaceonfire/presets/wordpress/nginx/vhost.common.d/10-location-root.conf deleted file mode 100644 index e8754d3..0000000 --- a/spaceonfire/presets/wordpress/nginx/vhost.common.d/10-location-root.conf +++ /dev/null @@ -1,3 +0,0 @@ -location / { - try_files $uri $uri/ /index.php?$args; -} diff --git a/test/single-entrypoint/docker-compose.yml b/test/single-entrypoint/docker-compose.yml new file mode 100644 index 0000000..bd2912b --- /dev/null +++ b/test/single-entrypoint/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' + +services: + test: + build: ../../ + image: spaceonfire/nginx-php-fpm:next + ports: + - 8080:80 + environment: + - SOF_PRESET=single-entrypoint + - ENTRYPOINT_SCRIPT=router.php + - PAGER=more