diff --git a/Dockerfile.development b/Dockerfile.development index 0872a15e6c1..bab3289db8a 100644 --- a/Dockerfile.development +++ b/Dockerfile.development @@ -42,7 +42,7 @@ COPY chromium /usr/bin/ WORKDIR /app -RUN groupadd osuweb && useradd -g osuweb osuweb +RUN groupadd osuweb && useradd -g osuweb -d /app/.docker osuweb ENTRYPOINT ["/app/docker/development/entrypoint.sh"] CMD ["octane"] diff --git a/docker/development/entrypoint.sh b/docker/development/entrypoint.sh index 9d23169e534..197942bf7a4 100755 --- a/docker/development/entrypoint.sh +++ b/docker/development/entrypoint.sh @@ -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 "$@" diff --git a/docker/development/run.sh b/docker/development/run.sh new file mode 100755 index 00000000000..372b5991eb7 --- /dev/null +++ b/docker/development/run.sh @@ -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