Last active
June 19, 2026 14:46
-
-
Save akatche/e8387e839387d31e22170696fcbd5d01 to your computer and use it in GitHub Desktop.
Run Laravel parallel tests using Laravel Sail
This file contains hidden or 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 hidden or 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 hidden or 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
HI can you confirm for me how the process works nowadays? I'm currently trying to setup standard Dusk testing with a testing DB and we're running into an issue with our docker compose site. Dusk is properly switching over to the .env.dusk values but the app is not. I'm not certain how we would be able to have our app switch its .env values over just from running the dusk test command. Preferably we would not be manually rebuilding the image and have everything work just from running dusk test normally, but i'm having a hard time understanding how we could re-up/down the container from inside the container.
Just to reiterate, we have 2 dbs in one mysql container, we're not using sail, and the issue is that Dusk runs with the correct env but hits the site that is using the old one.