diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ba5d17..f581e3d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # Release Notes -## [Unreleased](https://github.com/laravel/sail/compare/v1.18.1...1.x) +## [Unreleased](https://github.com/laravel/sail/compare/v1.19.0...1.x) + +## [v1.19.0](https://github.com/laravel/sail/compare/v1.18.1...v1.19.0) - 2023-01-31 + +### Added + +- Add custom domain config to sail share by @mojowill in https://github.com/laravel/sail/pull/531 +- Add pest command to sail bin by @MortenDHansen in https://github.com/laravel/sail/pull/534 + +### Changed + +- Replace mailhog with mailpit by @ankurk91 in https://github.com/laravel/sail/pull/533 ## [v1.18.1](https://github.com/laravel/sail/compare/v1.18.0...v1.18.1) - 2023-01-12 diff --git a/composer.json b/composer.json index 23585d57..3280caa2 100644 --- a/composer.json +++ b/composer.json @@ -15,9 +15,10 @@ ], "require": { "php": "^7.3|^8.0", - "illuminate/contracts": "^8.0|^9.0|^10.0", "illuminate/console": "^8.0|^9.0|^10.0", - "illuminate/support": "^8.0|^9.0|^10.0" + "illuminate/contracts": "^8.0|^9.0|^10.0", + "illuminate/support": "^8.0|^9.0|^10.0", + "symfony/yaml": "^6.0" }, "bin": [ "bin/sail" diff --git a/src/Console/AddCommand.php b/src/Console/AddCommand.php new file mode 100644 index 00000000..36c2cc92 --- /dev/null +++ b/src/Console/AddCommand.php @@ -0,0 +1,57 @@ +argument('services')) { + $services = $this->argument('services') == 'none' ? [] : explode(',', $this->argument('services')); + } elseif ($this->option('no-interaction')) { + $services = $this->defaultServices; + } else { + $services = $this->gatherServicesWithSymfonyMenu(); + } + + if ($invalidServices = array_diff($services, $this->services)) { + $this->error('Invalid services ['.implode(',', $invalidServices).'].'); + + return 1; + } + + $this->buildDockerCompose($services); + $this->replaceEnvVariables($services); + $this->configurePhpUnit(); + + $this->info('Additional Sail services installed successfully.'); + + $this->prepareInstallation($services); + } +} diff --git a/src/Console/Concerns/InteractsWithDockerComposeServices.php b/src/Console/Concerns/InteractsWithDockerComposeServices.php new file mode 100644 index 00000000..0cea8618 --- /dev/null +++ b/src/Console/Concerns/InteractsWithDockerComposeServices.php @@ -0,0 +1,252 @@ + + */ + protected $services = [ + 'mysql', + 'pgsql', + 'mariadb', + 'redis', + 'memcached', + 'meilisearch', + 'minio', + 'mailpit', + 'selenium', + 'soketi', + ]; + + /** + * The default services used when the user chooses non-interactive mode. + * + * @var string[] + */ + protected $defaultServices = ['mysql', 'redis', 'selenium', 'mailpit']; + + /** + * Gather the desired Sail services using a Symfony menu. + * + * @return array + */ + protected function gatherServicesWithSymfonyMenu() + { + return $this->choice('Which services would you like to install?', $this->services, 0, null, true); + } + + /** + * Build the Docker Compose file. + * + * @param array $services + * @return void + */ + protected function buildDockerCompose(array $services) + { + $composePath = base_path('docker-compose.yml'); + + $compose = file_exists($composePath) + ? Yaml::parseFile($composePath) + : Yaml::parse(file_get_contents(__DIR__ . '/../../../stubs/docker-compose.stub')); + + // Adds the new services as dependencies of the laravel.test service... + if (! array_key_exists('laravel.test', $compose['services'])) { + $this->warn('Couldn\'t find the laravel.test service. Make sure you add ['.implode(',', $services).'] to the depends_on config.'); + } else { + $compose['services']['laravel.test']['depends_on'] = collect($compose['services']['laravel.test']['depends_on'] ?? []) + ->merge($services) + ->unique() + ->values() + ->all(); + } + + // Add the services to the docker-compose.yml... + collect($services) + ->filter(function ($service) use ($compose) { + return ! array_key_exists($service, $compose['services'] ?? []); + })->each(function ($service) use (&$compose) { + $compose['services'][$service] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")[$service]; + }); + + // Merge volumes... + collect($services) + ->filter(function ($service) { + return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'meilisearch', 'minio']); + })->filter(function ($service) use ($compose) { + return ! array_key_exists($service, $compose['volumes'] ?? []); + })->each(function ($service) use (&$compose) { + $compose['volumes']["sail-{$service}"] = ['driver' => 'local']; + }); + + // If the list of volumes is empty, we can remove it... + if (empty($compose['volumes'])) { + unset($compose['volumes']); + } + + // Replace Selenium with ARM base container on Apple Silicon... + if (in_array('selenium', $services) && in_array(php_uname('m'), ['arm64', 'aarch64'])) { + $compose['services']['selenium']['image'] = 'seleniarm/standalone-chromium'; + } + + file_put_contents($this->laravel->basePath('docker-compose.yml'), Yaml::dump($compose, Yaml::DUMP_OBJECT_AS_MAP)); + } + + /** + * Replace the Host environment variables in the app's .env file. + * + * @param array $services + * @return void + */ + protected function replaceEnvVariables(array $services) + { + $environment = file_get_contents($this->laravel->basePath('.env')); + + if (in_array('pgsql', $services)) { + $environment = str_replace('DB_CONNECTION=mysql', "DB_CONNECTION=pgsql", $environment); + $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=pgsql", $environment); + $environment = str_replace('DB_PORT=3306', "DB_PORT=5432", $environment); + } elseif (in_array('mariadb', $services)) { + $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=mariadb", $environment); + } else { + $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=mysql", $environment); + } + + $environment = str_replace('DB_USERNAME=root', "DB_USERNAME=sail", $environment); + $environment = preg_replace("/DB_PASSWORD=(.*)/", "DB_PASSWORD=password", $environment); + + if (in_array('memcached', $services)) { + $environment = str_replace('MEMCACHED_HOST=127.0.0.1', 'MEMCACHED_HOST=memcached', $environment); + } + + if (in_array('redis', $services)) { + $environment = str_replace('REDIS_HOST=127.0.0.1', 'REDIS_HOST=redis', $environment); + } + + if (in_array('meilisearch', $services)) { + $environment .= "\nSCOUT_DRIVER=meilisearch"; + $environment .= "\nMEILISEARCH_HOST=http://meilisearch:7700\n"; + } + + if (in_array('soketi', $services)) { + $environment = preg_replace("/^BROADCAST_DRIVER=(.*)/m", "BROADCAST_DRIVER=pusher", $environment); + $environment = preg_replace("/^PUSHER_APP_ID=(.*)/m", "PUSHER_APP_ID=app-id", $environment); + $environment = preg_replace("/^PUSHER_APP_KEY=(.*)/m", "PUSHER_APP_KEY=app-key", $environment); + $environment = preg_replace("/^PUSHER_APP_SECRET=(.*)/m", "PUSHER_APP_SECRET=app-secret", $environment); + $environment = preg_replace("/^PUSHER_HOST=(.*)/m", "PUSHER_HOST=soketi", $environment); + $environment = preg_replace("/^PUSHER_PORT=(.*)/m", "PUSHER_PORT=6001", $environment); + $environment = preg_replace("/^PUSHER_SCHEME=(.*)/m", "PUSHER_SCHEME=http", $environment); + $environment = preg_replace("/^VITE_PUSHER_HOST=(.*)/m", "VITE_PUSHER_HOST=localhost", $environment); + } + + if (in_array('mailpit', $services)) { + $environment = preg_replace("/^MAIL_HOST=(.*)/m", "MAIL_HOST=mailpit", $environment); + } + + file_put_contents($this->laravel->basePath('.env'), $environment); + } + + /** + * Configure PHPUnit to use the dedicated testing database. + * + * @return void + */ + protected function configurePhpUnit() + { + if (! file_exists($path = $this->laravel->basePath('phpunit.xml'))) { + $path = $this->laravel->basePath('phpunit.xml.dist'); + } + + $phpunit = file_get_contents($path); + + $phpunit = preg_replace('/^.*DB_CONNECTION.*\n/m', '', $phpunit); + $phpunit = str_replace('', '', $phpunit); + + file_put_contents($this->laravel->basePath('phpunit.xml'), $phpunit); + } + + /** + * Install the devcontainer.json configuration file. + * + * @return void + */ + protected function installDevContainer() + { + if (! is_dir($this->laravel->basePath('.devcontainer'))) { + mkdir($this->laravel->basePath('.devcontainer'), 0755, true); + } + + file_put_contents( + $this->laravel->basePath('.devcontainer/devcontainer.json'), + file_get_contents(__DIR__.'/../../stubs/devcontainer.stub') + ); + + $environment = file_get_contents($this->laravel->basePath('.env')); + + $environment .= "\nWWWGROUP=1000"; + $environment .= "\nWWWUSER=1000\n"; + + file_put_contents($this->laravel->basePath('.env'), $environment); + } + + /** + * Prepare the installation by pulling and building any necessary images. + * + * @param array $services + * @return void + */ + protected function prepareInstallation($services) + { + // Ensure docker is installed... + if ($this->runCommands(['docker info > /dev/null 2>&1']) !== 0) { + return; + } + + if (count($services) > 0) { + $status = $this->runCommands([ + './vendor/bin/sail pull '.implode(' ', $services), + ]); + + if ($status === 0) { + $this->info('Sail images installed successfully.'); + } + } + + $status = $this->runCommands([ + './vendor/bin/sail build', + ]); + + if ($status === 0) { + $this->info('Sail build successful.'); + } + } + + /** + * Run the given commands. + * + * @param array $commands + * @return int + */ + protected function runCommands($commands) + { + $process = Process::fromShellCommandline(implode(' && ', $commands), null, null, null, null); + + if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { + try { + $process->setTty(true); + } catch (\RuntimeException $e) { + $this->output->writeln(' WARN '.$e->getMessage().PHP_EOL); + } + } + + return $process->run(function ($type, $line) { + $this->output->write(' '.$line); + }); + } +} diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index eefb0ffc..5bc286e5 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -8,6 +8,8 @@ class InstallCommand extends Command { + use Concerns\InteractsWithDockerComposeServices; + /** * The name and signature of the console command. * @@ -24,23 +26,6 @@ class InstallCommand extends Command */ protected $description = 'Install Laravel Sail\'s default Docker Compose file'; - /** - * The available services that may be installed. - * - * @var array - */ - protected $services = [ - 'mysql', - 'pgsql', - 'mariadb', - 'redis', - 'memcached', - 'meilisearch', - 'minio', - 'mailpit', - 'selenium', - ]; - /** * Execute the console command. * @@ -51,7 +36,7 @@ public function handle() if ($this->option('with')) { $services = $this->option('with') == 'none' ? [] : explode(',', $this->option('with')); } elseif ($this->option('no-interaction')) { - $services = ['mysql', 'redis', 'selenium', 'mailpit']; + $services = $this->defaultServices; } else { $services = $this->gatherServicesWithSymfonyMenu(); } @@ -74,191 +59,4 @@ public function handle() $this->prepareInstallation($services); } - - /** - * Gather the desired Sail services using a Symfony menu. - * - * @return array - */ - protected function gatherServicesWithSymfonyMenu() - { - return $this->choice('Which services would you like to install?', $this->services, 0, null, true); - } - - /** - * Build the Docker Compose file. - * - * @param array $services - * @return void - */ - protected function buildDockerCompose(array $services) - { - $depends = collect($services) - ->map(function ($service) { - return " - {$service}"; - })->whenNotEmpty(function ($collection) { - return $collection->prepend('depends_on:'); - })->implode("\n"); - - $stubs = rtrim(collect($services)->map(function ($service) { - return file_get_contents(__DIR__ . "/../../stubs/{$service}.stub"); - })->implode('')); - - $volumes = collect($services) - ->filter(function ($service) { - return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'meilisearch', 'minio']); - })->map(function ($service) { - return " sail-{$service}:\n driver: local"; - })->whenNotEmpty(function ($collection) { - return $collection->prepend('volumes:'); - })->implode("\n"); - - $dockerCompose = file_get_contents(__DIR__ . '/../../stubs/docker-compose.stub'); - - $dockerCompose = str_replace('{{depends}}', empty($depends) ? '' : ' '.$depends, $dockerCompose); - $dockerCompose = str_replace('{{services}}', $stubs, $dockerCompose); - $dockerCompose = str_replace('{{volumes}}', $volumes, $dockerCompose); - - // Replace Selenium with ARM base container on Apple Silicon... - if (in_array('selenium', $services) && php_uname('m') === 'arm64') { - $dockerCompose = str_replace('selenium/standalone-chrome', 'seleniarm/standalone-chromium', $dockerCompose); - } - - // Remove empty lines... - $dockerCompose = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $dockerCompose); - - file_put_contents($this->laravel->basePath('docker-compose.yml'), $dockerCompose); - } - - /** - * Replace the Host environment variables in the app's .env file. - * - * @param array $services - * @return void - */ - protected function replaceEnvVariables(array $services) - { - $environment = file_get_contents($this->laravel->basePath('.env')); - - if (in_array('pgsql', $services)) { - $environment = str_replace('DB_CONNECTION=mysql', "DB_CONNECTION=pgsql", $environment); - $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=pgsql", $environment); - $environment = str_replace('DB_PORT=3306', "DB_PORT=5432", $environment); - } elseif (in_array('mariadb', $services)) { - $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=mariadb", $environment); - } else { - $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=mysql", $environment); - } - - $environment = str_replace('DB_USERNAME=root', "DB_USERNAME=sail", $environment); - $environment = preg_replace("/DB_PASSWORD=(.*)/", "DB_PASSWORD=password", $environment); - - $environment = str_replace('MEMCACHED_HOST=127.0.0.1', 'MEMCACHED_HOST=memcached', $environment); - $environment = str_replace('REDIS_HOST=127.0.0.1', 'REDIS_HOST=redis', $environment); - - if (in_array('meilisearch', $services)) { - $environment .= "\nSCOUT_DRIVER=meilisearch"; - $environment .= "\nMEILISEARCH_HOST=http://meilisearch:7700\n"; - } - - file_put_contents($this->laravel->basePath('.env'), $environment); - } - - /** - * Configure PHPUnit to use the dedicated testing database. - * - * @return void - */ - protected function configurePhpUnit() - { - if (! file_exists($path = $this->laravel->basePath('phpunit.xml'))) { - $path = $this->laravel->basePath('phpunit.xml.dist'); - } - - $phpunit = file_get_contents($path); - - $phpunit = preg_replace('/^.*DB_CONNECTION.*\n/m', '', $phpunit); - $phpunit = str_replace('', '', $phpunit); - - file_put_contents($this->laravel->basePath('phpunit.xml'), $phpunit); - } - - /** - * Install the devcontainer.json configuration file. - * - * @return void - */ - protected function installDevContainer() - { - if (! is_dir($this->laravel->basePath('.devcontainer'))) { - mkdir($this->laravel->basePath('.devcontainer'), 0755, true); - } - - file_put_contents( - $this->laravel->basePath('.devcontainer/devcontainer.json'), - file_get_contents(__DIR__.'/../../stubs/devcontainer.stub') - ); - - $environment = file_get_contents($this->laravel->basePath('.env')); - - $environment .= "\nWWWGROUP=1000"; - $environment .= "\nWWWUSER=1000\n"; - - file_put_contents($this->laravel->basePath('.env'), $environment); - } - - /** - * Prepare the installation by pulling and building any necessary images. - * - * @param array $services - * @return void - */ - protected function prepareInstallation($services) - { - // Ensure docker is installed... - if ($this->runCommands(['docker info > /dev/null 2>&1']) !== 0) { - return; - } - - if (count($services) > 0) { - $status = $this->runCommands([ - './vendor/bin/sail pull '.implode(' ', $services), - ]); - - if ($status === 0) { - $this->info('Sail images installed successfully.'); - } - } - - $status = $this->runCommands([ - './vendor/bin/sail build', - ]); - - if ($status === 0) { - $this->info('Sail build successful.'); - } - } - - /** - * Run the given commands. - * - * @param array $commands - * @return int - */ - protected function runCommands($commands) - { - $process = Process::fromShellCommandline(implode(' && ', $commands), null, null, null, null); - - if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { - try { - $process->setTty(true); - } catch (RuntimeException $e) { - $this->output->writeln(' WARN '.$e->getMessage().PHP_EOL); - } - } - - return $process->run(function ($type, $line) { - $this->output->write(' '.$line); - }); - } } diff --git a/src/SailServiceProvider.php b/src/SailServiceProvider.php index 4ca82a70..da30d9fc 100644 --- a/src/SailServiceProvider.php +++ b/src/SailServiceProvider.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Support\ServiceProvider; +use Laravel\Sail\Console\AddCommand; use Laravel\Sail\Console\InstallCommand; use Laravel\Sail\Console\PublishCommand; @@ -30,6 +31,7 @@ protected function registerCommands() if ($this->app->runningInConsole()) { $this->commands([ InstallCommand::class, + AddCommand::class, PublishCommand::class, ]); } diff --git a/stubs/devcontainer.stub b/stubs/devcontainer.stub index fb36850e..f14b7183 100644 --- a/stubs/devcontainer.stub +++ b/stubs/devcontainer.stub @@ -6,7 +6,6 @@ ], "service": "laravel.test", "workspaceFolder": "/var/www/html", - "settings": {}, "customizations": { "vscode": { "extensions": [ @@ -15,7 +14,8 @@ // "ryannaddy.laravel-artisan", // "onecentlin.laravel5-snippets", // "onecentlin.laravel-blade" - ] + ], + "settings": {} } }, "remoteUser": "sail", diff --git a/stubs/docker-compose.stub b/stubs/docker-compose.stub index 3ade78e1..d012e9eb 100644 --- a/stubs/docker-compose.stub +++ b/stubs/docker-compose.stub @@ -22,9 +22,6 @@ services: - '.:/var/www/html' networks: - sail -{{depends}} -{{services}} networks: sail: driver: bridge -{{volumes}} diff --git a/stubs/mailpit.stub b/stubs/mailpit.stub index 8aa62b94..9c4d807d 100644 --- a/stubs/mailpit.stub +++ b/stubs/mailpit.stub @@ -1,7 +1,7 @@ - mailpit: - image: 'axllent/mailpit:latest' - ports: - - '${FORWARD_MAILPIT_PORT:-1025}:1025' - - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025' - networks: - - sail +mailpit: + image: 'axllent/mailpit:latest' + ports: + - '${FORWARD_MAILPIT_PORT:-1025}:1025' + - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025' + networks: + - sail diff --git a/stubs/mariadb.stub b/stubs/mariadb.stub index 6beb6bc9..191cb9c8 100644 --- a/stubs/mariadb.stub +++ b/stubs/mariadb.stub @@ -1,20 +1,20 @@ - mariadb: - image: 'mariadb:10' - ports: - - '${FORWARD_DB_PORT:-3306}:3306' - environment: - MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' - MYSQL_ROOT_HOST: "%" - MYSQL_DATABASE: '${DB_DATABASE}' - MYSQL_USER: '${DB_USERNAME}' - MYSQL_PASSWORD: '${DB_PASSWORD}' - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - volumes: - - 'sail-mariadb:/var/lib/mysql' - - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' - networks: - - sail - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] - retries: 3 - timeout: 5s +mariadb: + image: 'mariadb:10' + ports: + - '${FORWARD_DB_PORT:-3306}:3306' + environment: + MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' + MYSQL_ROOT_HOST: "%" + MYSQL_DATABASE: '${DB_DATABASE}' + MYSQL_USER: '${DB_USERNAME}' + MYSQL_PASSWORD: '${DB_PASSWORD}' + MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' + volumes: + - 'sail-mariadb:/var/lib/mysql' + - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' + networks: + - sail + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] + retries: 3 + timeout: 5s diff --git a/stubs/meilisearch.stub b/stubs/meilisearch.stub index bd236c00..25c23c7b 100644 --- a/stubs/meilisearch.stub +++ b/stubs/meilisearch.stub @@ -1,12 +1,12 @@ - meilisearch: - image: 'getmeili/meilisearch:latest' - ports: - - '${FORWARD_MEILISEARCH_PORT:-7700}:7700' - volumes: - - 'sail-meilisearch:/meili_data' - networks: - - sail - healthcheck: - test: ["CMD", "wget", "--no-verbose", "--spider", "http://localhost:7700/health"] - retries: 3 - timeout: 5s +meilisearch: + image: 'getmeili/meilisearch:latest' + ports: + - '${FORWARD_MEILISEARCH_PORT:-7700}:7700' + volumes: + - 'sail-meilisearch:/meili_data' + networks: + - sail + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--spider", "http://localhost:7700/health"] + retries: 3 + timeout: 5s diff --git a/stubs/memcached.stub b/stubs/memcached.stub index d219b721..c713e22a 100644 --- a/stubs/memcached.stub +++ b/stubs/memcached.stub @@ -1,6 +1,6 @@ - memcached: - image: 'memcached:alpine' - ports: - - '${FORWARD_MEMCACHED_PORT:-11211}:11211' - networks: - - sail +memcached: + image: 'memcached:alpine' + ports: + - '${FORWARD_MEMCACHED_PORT:-11211}:11211' + networks: + - sail diff --git a/stubs/minio.stub b/stubs/minio.stub index 1a4dc03d..c15e3c5f 100644 --- a/stubs/minio.stub +++ b/stubs/minio.stub @@ -1,17 +1,17 @@ - minio: - image: 'minio/minio:latest' - ports: - - '${FORWARD_MINIO_PORT:-9000}:9000' - - '${FORWARD_MINIO_CONSOLE_PORT:-8900}:8900' - environment: - MINIO_ROOT_USER: 'sail' - MINIO_ROOT_PASSWORD: 'password' - volumes: - - 'sail-minio:/data/minio' - networks: - - sail - command: minio server /data/minio --console-address ":8900" - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] - retries: 3 - timeout: 5s +minio: + image: 'minio/minio:latest' + ports: + - '${FORWARD_MINIO_PORT:-9000}:9000' + - '${FORWARD_MINIO_CONSOLE_PORT:-8900}:8900' + environment: + MINIO_ROOT_USER: 'sail' + MINIO_ROOT_PASSWORD: 'password' + volumes: + - 'sail-minio:/data/minio' + networks: + - sail + command: minio server /data/minio --console-address ":8900" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] + retries: 3 + timeout: 5s diff --git a/stubs/mysql.stub b/stubs/mysql.stub index a775a2bc..c4d66f97 100644 --- a/stubs/mysql.stub +++ b/stubs/mysql.stub @@ -1,20 +1,20 @@ - mysql: - image: 'mysql/mysql-server:8.0' - ports: - - '${FORWARD_DB_PORT:-3306}:3306' - environment: - MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' - MYSQL_ROOT_HOST: "%" - MYSQL_DATABASE: '${DB_DATABASE}' - MYSQL_USER: '${DB_USERNAME}' - MYSQL_PASSWORD: '${DB_PASSWORD}' - MYSQL_ALLOW_EMPTY_PASSWORD: 1 - volumes: - - 'sail-mysql:/var/lib/mysql' - - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' - networks: - - sail - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] - retries: 3 - timeout: 5s +mysql: + image: 'mysql/mysql-server:8.0' + ports: + - '${FORWARD_DB_PORT:-3306}:3306' + environment: + MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' + MYSQL_ROOT_HOST: "%" + MYSQL_DATABASE: '${DB_DATABASE}' + MYSQL_USER: '${DB_USERNAME}' + MYSQL_PASSWORD: '${DB_PASSWORD}' + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + volumes: + - 'sail-mysql:/var/lib/mysql' + - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' + networks: + - sail + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] + retries: 3 + timeout: 5s diff --git a/stubs/pgsql.stub b/stubs/pgsql.stub index 5aee7954..fef85da6 100644 --- a/stubs/pgsql.stub +++ b/stubs/pgsql.stub @@ -1,18 +1,18 @@ - pgsql: - image: 'postgres:15' - 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: - - 'sail-pgsql:/var/lib/postgresql/data' - - './vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql' - networks: - - sail - healthcheck: - test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"] - retries: 3 - timeout: 5s +pgsql: + image: 'postgres:15' + 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: + - 'sail-pgsql:/var/lib/postgresql/data' + - './vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql' + networks: + - sail + healthcheck: + test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"] + retries: 3 + timeout: 5s diff --git a/stubs/redis.stub b/stubs/redis.stub index 8bb88a1a..4297e063 100644 --- a/stubs/redis.stub +++ b/stubs/redis.stub @@ -1,12 +1,12 @@ - redis: - image: 'redis:alpine' - ports: - - '${FORWARD_REDIS_PORT:-6379}:6379' - volumes: - - 'sail-redis:/data' - networks: - - sail - healthcheck: - test: ["CMD", "redis-cli", "ping"] - retries: 3 - timeout: 5s +redis: + image: 'redis:alpine' + ports: + - '${FORWARD_REDIS_PORT:-6379}:6379' + volumes: + - 'sail-redis:/data' + networks: + - sail + healthcheck: + test: ["CMD", "redis-cli", "ping"] + retries: 3 + timeout: 5s diff --git a/stubs/selenium.stub b/stubs/selenium.stub index 9b107ba6..89ba7400 100644 --- a/stubs/selenium.stub +++ b/stubs/selenium.stub @@ -1,8 +1,8 @@ - selenium: - image: 'selenium/standalone-chrome' - extra_hosts: - - 'host.docker.internal:host-gateway' - volumes: - - '/dev/shm:/dev/shm' - networks: - - sail +selenium: + image: 'selenium/standalone-chrome' + extra_hosts: + - 'host.docker.internal:host-gateway' + volumes: + - '/dev/shm:/dev/shm' + networks: + - sail diff --git a/stubs/soketi.stub b/stubs/soketi.stub new file mode 100644 index 00000000..dad40561 --- /dev/null +++ b/stubs/soketi.stub @@ -0,0 +1,13 @@ +soketi: + image: 'quay.io/soketi/soketi:latest-16-alpine' + environment: + SOKETI_DEBUG: '${SOKETI_DEBUG:-1}' + SOKETI_METRICS_SERVER_PORT: '9601' + SOKETI_DEFAULT_APP_ID: '${PUSHER_APP_ID}' + SOKETI_DEFAULT_APP_KEY: '${PUSHER_APP_KEY}' + SOKETI_DEFAULT_APP_SECRET: '${PUSHER_APP_SECRET}' + ports: + - '${PUSHER_PORT:-6001}:6001' + - '${PUSHER_METRICS_PORT:-9601}:9601' + networks: + - sail