Skip to content

Commit

Permalink
Merge pull request #11784 from nanaya/app-key-dusk
Browse files Browse the repository at this point in the history
Fix env file setup for dusk.local
  • Loading branch information
notbakaneko authored Jan 14, 2025
2 parents 05c4a60 + 12b2a20 commit 10f70e2
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions docker/development/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ _run() {
docker compose run --rm php "$@"
}

_run_dusk() {
docker compose run --rm -e APP_ENV=dusk.local php "$@"
}

if [ ! -f .env ]; then
echo "Copying default env file"
cp .env.example .env
fi
for envfile in .env .env.testing .env.dusk.local; do
if [ ! -f "${envfile}" ]; then
echo "Copying env file '${envfile}'"
cp "${envfile}.example" "${envfile}"
fi
if [ "${envfile}" != .env.testing ] && ! grep -q '^APP_KEY=.' "${envfile}"; then
echo "Generating app key for env file '${envfile}'"
sed -i -e '/^APP_KEY=.*/d' "${envfile}"
: ${APP_KEY="base64:$(head -c 32 /dev/urandom | base64)"}
echo "APP_KEY=${APP_KEY}" >> "${envfile}"
fi
done

if [ -n "${GITHUB_TOKEN:-}" ]; then
_run composer config -g github-oauth.github.com "${GITHUB_TOKEN}"
grep ^GITHUB_TOKEN= .env || echo "GITHUB_TOKEN=${GITHUB_TOKEN}" >> .env
for envfile in .env .env.dusk.local; do
grep -q '^GITHUB_TOKEN=' "${envfile}" || echo "GITHUB_TOKEN=${GITHUB_TOKEN}" >> "${envfile}"
done
fi

docker compose build
Expand All @@ -37,23 +43,6 @@ _run composer install

_run artisan dusk:chrome-driver

if ! grep -q '^APP_KEY=.' .env; then
echo "Generating app key"
_run artisan key:generate
fi

if [ ! -f .env.testing ]; then
echo "Copying default test env file"
cp .env.testing.example .env.testing
fi

if [ ! -f .env.dusk.local ]; then
echo "Copying default dusk env file"
cp .env.dusk.local.example .env.dusk.local
echo "Generating app key for dusk"
_run_dusk artisan key:generate
fi

if [ -d storage/oauth-public.key ]; then
echo "oauth-public.key is a directory. Removing it"
rmdir storage/oauth-public.key
Expand Down

0 comments on commit 10f70e2

Please sign in to comment.