Skip to content

Instantly share code, notes, and snippets.

@kyleparisi kyleparisi/.env.testing
Last active Sep 7, 2019

Embed
What would you like to do?
Laravel + Docker testrig (alternative to homestead/valet?). Requires only docker as local dependency.
APP_ENV=testing
APP_KEY=base64:blahblah
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

Cleanup

docker-compose stop && docker-compose rm
#!/usr/bin/env bash
docker run --rm \
--user $(id -u):$(id -g) \
--volume $PWD:/var/www/default \
--volume $HOME/.composer:/.composer \
--workdir /var/www/default \
--entrypoint "composer" \
kyleparisi/larasible "$@"
version: '2'
services:
app:
image: kyleparisi/larasible
ports:
- 80:80
environment:
- APP_ENV=testing
volumes:
- ./:/var/www/default
mysql:
image: mysql:5.7
ports:
- 3306:3306
environment:
- MYSQL_DATABASE=homestead
- MYSQL_USER=homestead
- MYSQL_PASSWORD=secret
- MYSQL_ROOT_PASSWORD=secret
#!/usr/bin/env bash
docker run --rm \
--volume $PWD:/usr/src/app \
--workdir /usr/src/app \
node:8 npm "$@"
#!/usr/bin/env bash
set -e
[ -f ".env.testing" ] || $(echo Please make an .env.testing file and run: php artisan key:generate --env=testing; exit 1)
export $(cat .env.testing | grep -v ^# | xargs);
echo Starting services
docker-compose up -d
echo Host: 127.0.0.1
until docker-compose exec mysql mysql -h 127.0.0.1 -u $DB_USERNAME -p$DB_PASSWORD -D $DB_DATABASE --silent -e "show databases;"
do
echo "Waiting for database connection..."
sleep 5
done
echo Installing dependencies
./scripts/npm.sh install
./scripts/composer.sh install
echo Seeding database
rm -f bootstrap/cache/*.php
docker-compose exec app php artisan migrate --env=testing && echo Database migrated
docker-compose exec app php artisan db:seed --env=testing && echo Database seeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.