docker-compose stop && docker-compose rm
Last active
January 28, 2020 19:35
-
-
Save kyleparisi/b1fa7e0da8a5ac64c6c340c72f67ba49 to your computer and use it in GitHub Desktop.
Laravel + Docker testrig (alternative to homestead/valet?). Requires only docker as local dependency.
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
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= |
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
#!/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 "$@" |
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
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 |
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
#!/usr/bin/env bash | |
docker run --rm \ | |
--volume $PWD:/usr/src/app \ | |
--workdir /usr/src/app \ | |
node:8 npm "$@" |
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
#!/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 |
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
#!/bin/bash | |
set -e | |
export $(cat .env.default | grep -v ^# | xargs); | |
echo Starting services: | |
docker start $APP_NAME-pgsql || docker run --name $APP_NAME-pgsql -e POSTGRES_USER=$DB_USERNAME -e POSTGRES_PASSWORD=$DB_PASSWORD -p $DB_PORT:$DB_PORT -d postgres:9.6.9 | |
until PG_PASSWORD=$DB_PASSWORD pg_isready -h $DB_HOST -U $DB_USERNAME -d $DB_DATABASE | |
do | |
echo "Waiting for database connection..." | |
sleep 1 | |
done | |
echo Running migrations: | |
python3 ./manage.py migrate | |
echo Running format: | |
echo Running tests: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment