forked from ppy/osu-web
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify docker dev entrypoint script
- Loading branch information
Showing
3 changed files
with
17 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,13 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
set -u | ||
|
||
export CHROME_BIN=/usr/bin/chromium | ||
export DUSK_WEBDRIVER_BIN=/usr/bin/chromedriver | ||
export YARN_CACHE_FOLDER=/app/.docker/.yarn | ||
export COMPOSER_HOME=/app/.docker/.composer | ||
|
||
command=octane | ||
if [ "$#" -gt 0 ]; then | ||
command="$1" | ||
shift | ||
fi | ||
|
||
uid="$(stat -c "%u" /app)" | ||
gid="$(stat -c "%g" /app)" | ||
uid=$(stat -c "%u" /app) | ||
gid=$(stat -c "%g" /app) | ||
|
||
if [ "$uid" != 0 ]; then | ||
usermod -u "$uid" -o osuweb > /dev/null | ||
groupmod -g "$gid" -o osuweb > /dev/null | ||
fi | ||
|
||
usermod -d /app/.docker osuweb > /dev/null | ||
chown -f "${uid}:${gid}" .docker/js-build/assets .docker/js-build/builds || true | ||
|
||
# helper functions | ||
_rexec() { | ||
exec gosu osuweb "$@" | ||
} | ||
|
||
_run() { | ||
gosu osuweb "$@" | ||
} | ||
|
||
# commands | ||
_job() { | ||
_rexec php /app/artisan queue:listen --queue=notification,default,beatmap_high,beatmap_default,store-notifications --tries=3 --timeout=1000 | ||
} | ||
|
||
_migrate() { | ||
_run php /app/artisan db:create | ||
_rexec php /app/artisan migrate:fresh-or-run | ||
} | ||
|
||
_octane() { | ||
_rexec /app/artisan octane:start --host=0.0.0.0 "$@" | ||
} | ||
|
||
_schedule() { | ||
_rexec php /app/artisan schedule:work | ||
} | ||
|
||
_test() { | ||
command=phpunit | ||
if [ "$#" -gt 0 ]; then | ||
command="$1" | ||
shift | ||
fi | ||
|
||
case "$command" in | ||
browser) _test_browser "$@";; | ||
js) _rexec yarn karma start --single-run --browsers ChromeHeadless "$@";; | ||
phpunit) _rexec ./bin/phpunit.sh "$@";; | ||
esac | ||
} | ||
|
||
_test_browser() { | ||
export APP_ENV=dusk.local | ||
_rexec php /app/artisan dusk "$@" | ||
} | ||
|
||
|
||
_watch() { | ||
_run yarn --network-timeout 100000 | ||
_rexec yarn watch | ||
} | ||
chown -f "${uid}:${gid}" .docker/js-build/assets .docker/js-build/builds | ||
|
||
case "$command" in | ||
artisan) _rexec php /app/artisan "$@";; | ||
job|migrate|octane|schedule|test|watch) "_$command" "$@";; | ||
*) _rexec "$command" "$@";; | ||
esac | ||
exec gosu osuweb /app/docker/development/run.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters