diff --git a/README.md b/README.md index ea04333d..dd0cf93f 100644 --- a/README.md +++ b/README.md @@ -317,15 +317,15 @@ The following variables trigger actions run by the [entrypoint script](./docker- | FWD_REMOTE_IP | false | `true` enables remote IP forwarding from proxy (Apache) | | INIT_WINTER | false | `true` runs winter up on container start | | CMS_ADMIN_PASSWORD | | Sets CMS admin password if INIT_WINTER `true` | -| COMPOSER_MERGE_PLUGINS | false | `true` adds merge plugins into the base composer.json | -| COMPOSER_UPDATE | false | `true` runs composer update in the base laravel directory to update winter and plugins (with persistent storage this will only run once) | -| COMPOSER_REQUIRE | | runs composer require with the provided space seperated list of winter plugins (or any required composer package) | +| COMPOSER_MERGE_PLUGINS | false | `true` adds merge plugins into the base composer.json. This should only run once | +| COMPOSER_UPDATE | false | `true` runs composer update in the base laravel directory to update winter and plugins | +| COMPOSER_REQUIRE | | runs composer require with the provided space seperated list of winter plugins (or any required composer package). This should only run once | | PHP_DISPLAY_ERRORS | off | Override value for `display_errors` in docker-wn-php.ini | | PHP_MEMORY_LIMIT | 128M | Override value for `memory_limit` in docker-wn-php.ini | | PHP_POST_MAX_SIZE | 32M | Override value for `post_max_size` in docker-wn-php.ini | | PHP_UPLOAD_MAX_FILESIZE | 32M | Override value for `upload_max_filesize` in docker-wn-php.ini | | VERSION_INFO | false | `true` outputs container current commit, php version, and dependency info on start | -| INIT_CERTBOT | false | `true` runs certbot to generate ssl certificates for the container | +| INIT_CERTBOT | false | `true` runs certbot to generate ssl certificates for the container. This should only run once | | LETSENCRYPT_HOST | | Sets the domain for certbot to generate a certificate for | | LETSENCRYPT_EMAIL | | Sets the email for certbot to use when generating a certificate | diff --git a/templates/docker-wn-entrypoint b/templates/docker-wn-entrypoint index b7811ea0..64793e36 100755 --- a/templates/docker-wn-entrypoint +++ b/templates/docker-wn-entrypoint @@ -31,7 +31,7 @@ fi if [ "${VERSION_INFO,,}" == "true" ]; then php --version | grep PHP -m 1 composer info | grep winter | awk '{print $1 ": " $2}' - php artisan winter:version + php artisan winter:version || (true && echo 'winter:version failed, dependencies probably not installed yet...') echo "---" fi @@ -51,11 +51,31 @@ elif [ "$1" == cron ]; then php artisan schedule:run fi +# install listed plugins using composer require (space separated list) +REQUIRE_MARK_FILE=.composer_did_require +if [ ! -z "$COMPOSER_REQUIRE" ] && [[ ! -f "$REQUIRE_MARK_FILE" ]]; then + echo 'composer require...' + composer require --no-scripts $COMPOSER_REQUIRE && touch $REQUIRE_MARK_FILE + + docker-wn-fix-permissions +fi + # modify base composer.json to include plugins for merge plugin # this is useful for development environments with mounted plugins -if [ "${COMPOSER_MERGE_PLUGINS,,}" == "true" ]; then +MERGE_PLUGINS_MARK_FILE=.composer_did_merge_plugins +if [ "${COMPOSER_MERGE_PLUGINS,,}" == "true" ] && [[ ! -f "$MERGE_PLUGINS_MARK_FILE" ]]; then echo 'composer merge plugins...' - composer config --merge extra.merge-plugin.include 'plugins/*/*/composer.json' + composer config --merge extra.merge-plugin.include 'plugins/*/*/composer.json' && composer install --no-scripts && touch $MERGE_PLUGINS_MARK_FILE + + docker-wn-fix-permissions +fi + +# update winter and plugins using composer update +if [ "${COMPOSER_UPDATE,,}" == "true" ] || [ "${COMPOSER_UPDATE,,}" == "force" ]; then + echo 'composer updating...' + composer update + + docker-wn-fix-permissions fi # Run winter up on container start @@ -68,28 +88,18 @@ if [ "${INIT_WINTER,,}" == "true" ]; then if [ ! -z "$CMS_ADMIN_PASSWORD" ]; then echo 'Update Winter CMS admin password...' # try with lower case first and catch error - php artisan winter:passwd admin $CMS_ADMIN_PASSWORD || (true && echo 'admin user not found, trying with upper case...') - # try with upper case - php artisan winter:passwd Admin $CMS_ADMIN_PASSWORD + php artisan winter:passwd admin $CMS_ADMIN_PASSWORD || \ + ( + true && echo 'admin user not found, trying with upper case...' && \ + # try with upper case + php artisan winter:passwd Admin $CMS_ADMIN_PASSWORD || \ + ( + true && echo 'Admin user not found! unable to set password!' + ) + ) fi fi -# update winter and plugins using composer update -if [ "${COMPOSER_UPDATE,,}" == "true" ] || [ "${COMPOSER_UPDATE,,}" == "force" ]; then - echo 'composer updating...' - composer update - - docker-wn-fix-permissions -fi - -# install listed plugins using composer require (space separated list) -if [ ! -z "$COMPOSER_REQUIRE" ]; then - echo 'composer require...' - composer require $COMPOSER_REQUIRE - - docker-wn-fix-permissions -fi - # run certbot setup one time CERTBOT_MARK_FILE=.certbot_did_initialise if [ "${INIT_CERTBOT,,}" == "true" ] && [[ ! -f "$CERTBOT_MARK_FILE" ]]; then