diff --git a/src/.s2i/bin/assemble-swoole b/src/.s2i/bin/assemble-swoole new file mode 100644 index 00000000..b548fa6a --- /dev/null +++ b/src/.s2i/bin/assemble-swoole @@ -0,0 +1,19 @@ +#!/bin/bash + +set -x +set -e +pwd + +if [ -f "composer.json" ]; then + echo "Detected composer.json, running install" + php -dmemory_limit=${COMPOSER_MEMORY_LIMIT:--1} /usr/bin/composer install ${COMPOSER_ARGS} + rm -rf ~/.cache/composer/ +fi + +if [ -z "${LARAVEL_ENV}" ]; then + LARAVEL_ENV=prod +fi + +npm install +npm run ${LARAVEL_ENV} && rm -rf ~/.npm/ + diff --git a/src/.s2i/bin/run b/src/.s2i/bin/run index 7c021ea9..d0761425 100755 --- a/src/.s2i/bin/run +++ b/src/.s2i/bin/run @@ -1,60 +1,68 @@ #!/bin/bash shopt -s dotglob pushd /opt/app-root/src echo "----> Remove bootstrap cache" find bootstrap/cache/ -type f ! -name ".gitignore" -delete if [ -z ${APP_KEY} ]; then echo "----> Run artisan key:generate" ./artisan key:generate + unset APP_KEY fi if [ -z ${JWT_SECRET} ]; then echo "----> Run artisan jwt:secret" ./artisan jwt:secret --always-no fi echo "----> Run artisan clear-compiled" ./artisan clear-compiled -echo "----> Run artisan cache:clear" -./artisan ${ARTISAN_VERBOSITY} cache:clear || true +if [[ "${LARAVEL_ENV}" != "production" || "$LARAVEL_ENV{}" != "prod" ]] + echo "----> Run artisan cache:clear" + ./artisan ${ARTISAN_VERBOSITY} cache:clear || true +fi # rpm -qv chromium # if [ ! -z "$(rpm -qv chromium 2>/dev/null)" ]; then # echo "---- Run artisan dusk:chrome-driver" # chver=$(rpmquery --queryformat="%{VERSION}" chromium | awk -F'.' '{print $1}') # ./artisan dusk:chrome-driver ${chver} # fi if [ ! -f 'resources/countries.php' ]; then echo "----> Run artisan data:countries" ./artisan data:countries fi rm -rvf bootstrap/cache/ mkdir -vp bootstrap/cache/ chown default bootstrap/cache ./artisan db:ping --wait || exit 1 ./artisan migrate --force || : #./artisan db:seed --force || : +env + case ${HKCCP_APP} in worker|WORKER ) echo "----> Running worker " - ./artisan queue:work;; + exec ./artisan queue:work;; server|SERVER ) echo "----> Running server " - ./artisan serve;; + exec ./artisan serve;; apache|APACHE|httpd|HTTPD ) echo "----> Starting httpd " /usr/libexec/s2i/run 2>&1;; + swoole|SWOOLE ) + echo "----> Running swoole" + exec ./artisan swoole:http start;; * ) echo "----> Sleeping" - sleep 10000;; + exec sleep 10000;; esac