Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Mar 25, 2024
1 parent 216fbd2 commit fdc834a
Showing 1 changed file with 34 additions and 58 deletions.
92 changes: 34 additions & 58 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit fdc834a

Please sign in to comment.