Skip to content

Commit

Permalink
Merge pull request #2 from MPO-Web-Consulting/develop
Browse files Browse the repository at this point in the history
bug fixes to order of entrypoint tasks
  • Loading branch information
mik-p authored Jan 31, 2024
2 parents 651b7e8 + a91b81d commit bce058e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
54 changes: 32 additions & 22 deletions templates/docker-wn-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bce058e

Please sign in to comment.