-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11638 from nanaya/docker-entrypoint-script-2
Simplify docker dev entrypoint script
- Loading branch information
Showing
3 changed files
with
64 additions
and
76 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" .) | ||
gid=$(stat -c "%g" .) | ||
|
||
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 ./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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
|
||
export CHROME_BIN=/usr/bin/chromium | ||
export DUSK_WEBDRIVER_BIN=/usr/bin/chromedriver | ||
|
||
command=octane | ||
if [ "$#" -gt 0 ]; then | ||
command="$1" | ||
shift | ||
fi | ||
|
||
# commands | ||
_job() { | ||
exec ./artisan queue:listen --queue=notification,default,beatmap_high,beatmap_default,store-notifications --tries=3 --timeout=1000 | ||
} | ||
|
||
_migrate() { | ||
./artisan db:create | ||
exec ./artisan migrate:fresh-or-run | ||
} | ||
|
||
_octane() { | ||
exec ./artisan octane:start --host=0.0.0.0 "$@" | ||
} | ||
|
||
_schedule() { | ||
exec ./artisan schedule:work | ||
} | ||
|
||
_test() { | ||
command=phpunit | ||
if [ "$#" -gt 0 ]; then | ||
command="$1" | ||
shift | ||
fi | ||
|
||
case "$command" in | ||
browser) _test_browser "$@";; | ||
js) exec yarn karma start --single-run --browsers ChromeHeadless "$@";; | ||
phpunit) exec ./bin/phpunit.sh "$@";; | ||
esac | ||
} | ||
|
||
_test_browser() { | ||
export APP_ENV=dusk.local | ||
exec ./artisan dusk "$@" | ||
} | ||
|
||
|
||
_watch() { | ||
yarn --network-timeout 100000 | ||
exec yarn watch | ||
} | ||
|
||
case "$command" in | ||
artisan) exec ./artisan "$@";; | ||
job|migrate|octane|schedule|test|watch) "_$command" "$@";; | ||
*) exec "$command" "$@";; | ||
esac |