From fdc834ae6802381e9ce6928ddeb14f33e2cd00fd Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Mon, 25 Mar 2024 10:59:42 -0300 Subject: [PATCH] more changes --- docker/start.sh | 92 ++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/docker/start.sh b/docker/start.sh index 94d9f73..8617a53 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,10 +1,12 @@ #!/usr/bin/env bash set -e +export WWWUSER=${WWWUSER:-$UID} +export WWWGROUP=${WWWGROUP:-$(id -g)} export ROLE=${CONTAINER_ROLE:-app} -export DB_HOST=database -export REDIS_HOST=redis -export DECODER_CONTAINER=decoder:8090 +export DB_HOST=${DOCKER_DB_HOST:-database} +export REDIS_HOST=${DOCKER_REDIS_HOST:-redis} +export DECODER_CONTAINER=${DECODER_CONTAINER:-"decoder:8090"} if [ ! -z "$WWWUSER" ]; then usermod -u $WWWUSER www-data @@ -17,69 +19,43 @@ fi chmod -R ugo+rw /.composer - npm install -composer update --prefer-dist --no-dev --no-interaction --ignore-platform-reqs -(cd vendor/gmajor/sr25519-bindings/go && GOFLAGS=-buildvcs=false go build -buildmode=c-shared -o sr25519.so . && mv sr25519.so ../src/Crypto/sr25519.so) -chown -hR www-data:www-data composer.lock package-lock.json vendor/ storage/ public/ node-modules/ vendor/gmajor/sr25519-bindings/src/Crypto/ +composer install --prefer-dist --no-dev --no-interaction --ignore-platform-reqs + +if [ ! -f vendor/gmajor/sr25519-bindings/src/Crypto/sr25519.so ]; then + (cd vendor/gmajor/sr25519-bindings/go && GOFLAGS=-buildvcs=false go build -buildmode=c-shared -o sr25519.so . && mv sr25519.so ../src/Crypto/sr25519.so) +fi +chown -hR www-data:www-data composer.lock package-lock.json vendor/ storage/ public/ node_modules/ vendor/gmajor/sr25519-bindings/ if ! [ -f config/log-viewer.php ]; then gosu www-data:www-data php artisan log-viewer:publish fi if ! [ -d public/vendor/platform-ui/build ]; then + # Platform-UI needs to check why we need to run this twice to make it work correctly. + gosu www-data:www-data php artisan platform-ui:install --route="/" --tenant="no" --skip + (cd vendor/enjin/platform-ui && npm install && npm run prod-laravel) + chown -hR www-data:www-data public vendor/enjin/platform-ui gosu www-data:www-data php artisan platform-ui:install --route="/" --tenant="no" --skip fi -gosu www-data:www-data php artisan optimize -gosu www-data:www-data php artisan view:cache -echo "Running apache..." -exec apache2-foreground - - -#else -# exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf -#fi - - -# -#echo "Caching configuration..." -#php artisan cache:clear && php artisan config:cache - -#if [ "$role" = "ingest" ]; then -# echo "Running ingest..." -# php artisan migrate && php artisan platform:sync && php artisan platform:ingest -#elif [ "$role" = "app" ]; then - - - - -#elif [ "$role" = "websocket" ]; then -# echo "Running queue and websocket..." -# supervisord && supervisorctl start horizon -# php artisan websockets:serve -#elif [ "$role" = "beam" ]; then -# echo "Running beam..." -# php artisan platform:process-beam-claims -#else -# echo "Could not match the container role \"$role\"" -# exit 1 -#fi - - -# -## Source the ".env" file so Laravel's environment variables are available... -## shellcheck source=/dev/null -#if [ -n "$APP_ENV" ] && [ -f ./.env."$APP_ENV" ]; then -# source ./.env."$APP_ENV"; -#elif [ -f ./.env ]; then -# source ./.env; -#fi -# -## Define environment variables... -#export APP_PORT=${APP_PORT:-80} -#export APP_SERVICE=${APP_SERVICE:-"laravel.test"} -#export DB_PORT=${DB_PORT:-3306} -#export WWWUSER=${WWWUSER:-$UID} -#export WWWGROUP=${WWWGROUP:-$(id -g)} +if [ "$ROLE" = "app" ]; then + echo "Running main application..." + gosu www-data:www-data php artisan optimize + gosu www-data:www-data php artisan view:cache + exec apache2-foreground +elif [ "$ROLE" = "ingest" ]; then + echo "Running platform ingest..." + php artisan migrate && php artisan platform:sync && php artisan platform:ingest +elif [ "$ROLE" = "websocket" ]; then + echo "Running queue and websocket..." + supervisord && supervisorctl start horizon + php artisan websockets:serve +elif [ "$ROLE" = "beam" ]; then + echo "Running beams..." + php artisan platform:process-beam-claims +else + echo "Could not match the container role \"$ROLE\"" + exit 1 +fi