Last active
October 7, 2022 13:08
-
-
Save akatche/e8387e839387d31e22170696fcbd5d01 to your computer and use it in GitHub Desktop.
Run Laravel parallel tests using Laravel Sail
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
# | |
# Create this file in the following folder docker/mysql/docker-entrypoint-initdb.d | |
# | |
CREATE DATABASE IF NOT EXISTS `test_1` COLLATE 'utf8_general_ci' ; | |
GRANT ALL ON `test_1`.* TO 'root'@'%' ; | |
CREATE DATABASE IF NOT EXISTS `test_2` COLLATE 'utf8_general_ci' ; | |
GRANT ALL ON `test_2`.* TO 'root'@'%' ; | |
CREATE DATABASE IF NOT EXISTS `test_3` COLLATE 'utf8_general_ci' ; | |
GRANT ALL ON `test_3`.* TO 'root'@'%' ; | |
# Create as many databases as processes you can run | |
FLUSH PRIVILEGES ; |
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
# For more information: https://laravel.com/docs/sail | |
version: '3' | |
services: | |
laravel.test: | |
build: | |
context: ./vendor/laravel/sail/runtimes/8.0 | |
dockerfile: Dockerfile | |
args: | |
WWWGROUP: '${WWWGROUP}' | |
image: sail-8.0/app | |
ports: | |
- '${APP_PORT:-80}:80' | |
environment: | |
WWWUSER: '${WWWUSER}' | |
LARAVEL_SAIL: 1 | |
volumes: | |
- '.:/var/www/html' | |
networks: | |
- sail | |
depends_on: | |
- mysql | |
# - pgsql | |
- redis | |
# - selenium | |
# selenium: | |
# image: 'selenium/standalone-chrome' | |
# volumes: | |
# - '/dev/shm:/dev/shm' | |
# networks: | |
# - sail | |
mysql: | |
image: 'mysql:8.0' | |
ports: | |
- '${FORWARD_DB_PORT:-3306}:3306' | |
environment: | |
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' | |
MYSQL_DATABASE: '${DB_DATABASE}' | |
MYSQL_USER: '${DB_USERNAME}' | |
MYSQL_PASSWORD: '${DB_PASSWORD}' | |
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' | |
volumes: | |
- 'sailmysql:/var/lib/mysql' | |
networks: | |
- sail | |
healthcheck: | |
test: ["CMD", "mysqladmin", "ping"] | |
mysql_test: | |
image: "mysql:8.0" | |
environment: | |
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}" | |
MYSQL_DATABASE: "${DB_DATABASE}" | |
MYSQL_USER: "${DB_USERNAME}" | |
MYSQL_PASSWORD: "${DB_PASSWORD}" | |
MYSQL_ALLOW_EMPTY_PASSWORD: "yes" | |
volumes: | |
- '${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d' | |
networks: | |
- sail | |
# pgsql: | |
# image: postgres:13 | |
# ports: | |
# - '${FORWARD_DB_PORT:-5432}:5432' | |
# environment: | |
# PGPASSWORD: '${DB_PASSWORD:-secret}' | |
# POSTGRES_DB: '${DB_DATABASE}' | |
# POSTGRES_USER: '${DB_USERNAME}' | |
# POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}' | |
# volumes: | |
# - 'sailpostgresql:/var/lib/postgresql/data' | |
# networks: | |
# - sail | |
# healthcheck: | |
# test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"] | |
redis: | |
image: 'redis:alpine' | |
ports: | |
- '${FORWARD_REDIS_PORT:-6379}:6379' | |
volumes: | |
- 'sailredis:/data' | |
networks: | |
- sail | |
healthcheck: | |
test: ["CMD", "redis-cli", "ping"] | |
# memcached: | |
# image: 'memcached:alpine' | |
# ports: | |
# - '11211:11211' | |
# networks: | |
# - sail | |
mailhog: | |
image: 'mailhog/mailhog:latest' | |
ports: | |
- '${FORWARD_MAILHOG_PORT:-1025}:1025' | |
- '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025' | |
networks: | |
- sail | |
networks: | |
sail: | |
driver: bridge | |
volumes: | |
sailmysql: | |
driver: local | |
# sailpostgresql: | |
# driver: local | |
sailredis: | |
driver: local |
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
DB_CONNECTION=mysql | |
DB_HOST=mysql_test | |
DB_PORT=3306 | |
DB_DATABASE=test | |
DB_USERNAME=root | |
DB_PASSWORD= | |
MYSQL_ENTRYPOINT_INITDB=./docker/mysql/docker-entrypoint-initdb.d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following steps are needed in order to run Laravel parallel tests on dedicated test databases