diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.yml b/.github/ISSUE_TEMPLATE/1_Bug_report.yml index a7f9f6eb..40cabd49 100644 --- a/.github/ISSUE_TEMPLATE/1_Bug_report.yml +++ b/.github/ISSUE_TEMPLATE/1_Bug_report.yml @@ -1,9 +1,9 @@ name: Bug Report -description: "Report a general library issue." +description: "Report something that's broken." body: - type: markdown attributes: - value: "Before submitting your report, [please ensure your Laravel version is still supported](https://laravel.com/docs/releases#support-policy)." + value: "Please read [our full contribution guide](https://laravel.com/docs/contributions#bug-reports) before submitting bug reports. If you notice improper DocBlock, PHPStan, or IDE warnings while using Laravel, do not create a GitHub issue. Instead, please submit a pull request to fix the problem." - type: input attributes: label: Sail Version @@ -14,7 +14,7 @@ body: - type: input attributes: label: Laravel Version - description: Provide the Laravel version that you are using. + description: Provide the Laravel version that you are using. [Please ensure it is still supported.](https://laravel.com/docs/releases#support-policy) placeholder: 10.4.1 validations: required: true diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index efea805e..368c1858 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -12,30 +12,4 @@ permissions: jobs: tests: - runs-on: ubuntu-22.04 - - strategy: - fail-fast: true - - name: Static Analysis - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - tools: composer:v2 - coverage: none - - - name: Install dependencies - uses: nick-fields/retry@v2 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - - name: Execute type checking - run: vendor/bin/phpstan + uses: laravel/.github/.github/workflows/static-analysis.yml@main diff --git a/CHANGELOG.md b/CHANGELOG.md index c860341f..eab5875e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,34 @@ # Release Notes -## [Unreleased](https://github.com/laravel/sail/compare/v1.26.3...1.x) +## [Unreleased](https://github.com/laravel/sail/compare/v1.28.0...1.x) + +## [v1.28.0](https://github.com/laravel/sail/compare/v1.27.4...v1.28.0) - 2024-02-20 + +* Changing pcov Directory by [@joaopalopes24](https://github.com/joaopalopes24) in https://github.com/laravel/sail/pull/670 +* add ffmpeg to support videos, when using Spatie media-library for Videos by [@negoziator](https://github.com/negoziator) in https://github.com/laravel/sail/pull/671 + +## [v1.27.4](https://github.com/laravel/sail/compare/v1.27.3...v1.27.4) - 2024-02-08 + +* Fix open in browser with APP_PORT by [@ijpatricio](https://github.com/ijpatricio) in https://github.com/laravel/sail/pull/663 + +## [v1.27.3](https://github.com/laravel/sail/compare/v1.27.2...v1.27.3) - 2024-01-30 + +* [1.x] Improves console output by [@nunomaduro](https://github.com/nunomaduro) in https://github.com/laravel/sail/pull/661 + +## [v1.27.2](https://github.com/laravel/sail/compare/v1.27.1...v1.27.2) - 2024-01-21 + +* Add Support for Typesense by [@jasonbosco](https://github.com/jasonbosco) in https://github.com/laravel/sail/pull/655 +* Lint sail script by [@dimitriacosta](https://github.com/dimitriacosta) in https://github.com/laravel/sail/pull/656 +* Make DB_CONNECTION replacement more robust by @taylorotwell in https://github.com/laravel/sail/commit/2276a8d9d6cfdcaad98bf67a34331d100149d5b6 + +## [v1.27.1](https://github.com/laravel/sail/compare/v1.27.0...v1.27.1) - 2024-01-13 + +* [1.x] [#651] Don't do anything if no phpunit files are present by [@zack6849](https://github.com/zack6849) in https://github.com/laravel/sail/pull/652 + +## [v1.27.0](https://github.com/laravel/sail/compare/v1.26.3...v1.27.0) - 2024-01-03 + +* [1.x] Allow easy customization of the command ran by supervisor's PHP process by [@bram-pkg](https://github.com/bram-pkg) in https://github.com/laravel/sail/pull/645 +* [1.x] Default to PHP 8.3 by [@Jubeki](https://github.com/Jubeki) in https://github.com/laravel/sail/pull/647 ## [v1.26.3](https://github.com/laravel/sail/compare/v1.26.2...v1.26.3) - 2023-12-02 diff --git a/bin/sail b/bin/sail index fe1bb924..fd90966d 100755 --- a/bin/sail +++ b/bin/sail @@ -158,9 +158,8 @@ function sail_is_not_running { exit 1 } -# Define podman Compose command prefix... -podman compose &> /dev/null -if [ $? == 0 ]; then +# Define Podman Compose command prefix... +if podman compose &> /dev/null; then DOCKER_COMPOSE=(podman compose) else DOCKER_COMPOSE=(podman-compose) @@ -174,7 +173,7 @@ if [ -n "$SAIL_FILES" ]; then if [ -f "$FILE" ]; then DOCKER_COMPOSE+=(-f "$FILE") else - echo "${BOLD}Unable to find podman Compose file: '${FILE}'${NC}" >&2 + echo "${BOLD}Unable to find Docker Compose file: '${FILE}'${NC}" >&2 exit 1 fi @@ -425,7 +424,7 @@ elif [ "$1" == "pnpx" ]; then sail_is_not_running fi -# Proxy YARN commands to the "yarn" binary on the application container... +# Proxy Yarn commands to the "yarn" binary on the application container... elif [ "$1" == "yarn" ]; then shift 1 @@ -560,7 +559,14 @@ elif [ "$1" == "open" ]; then shift 1 if [ "$EXEC" == "yes" ]; then - open $APP_URL + + if [[ -n "$APP_PORT" && "$APP_PORT" != "80" ]]; then + FULL_URL="${APP_URL}:${APP_PORT}" + else + FULL_URL="$APP_URL" + fi + + open "$FULL_URL" exit else diff --git a/composer.json b/composer.json index 4735edba..241db95f 100644 --- a/composer.json +++ b/composer.json @@ -15,9 +15,9 @@ ], "require": { "php": "^8.0", - "illuminate/console": "^9.0|^10.0|^11.0", - "illuminate/contracts": "^9.0|^10.0|^11.0", - "illuminate/support": "^9.0|^10.0|^11.0", + "illuminate/console": "^9.52.16|^10.0|^11.0", + "illuminate/contracts": "^9.52.16|^10.0|^11.0", + "illuminate/support": "^9.52.16|^10.0|^11.0", "symfony/yaml": "^6.0|^7.0" }, "bin": [ diff --git a/runtimes/8.0/Dockerfile b/runtimes/8.0/Dockerfile index a6dabe6b..2bc1cb3d 100644 --- a/runtimes/8.0/Dockerfile +++ b/runtimes/8.0/Dockerfile @@ -16,7 +16,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt-get update \ && mkdir -p /etc/apt/keyrings \ - && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch \ + && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch ffmpeg \ && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null \ && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ && apt-get update \ diff --git a/runtimes/8.0/php.ini b/runtimes/8.0/php.ini index 39dcbcac..0320d71c 100644 --- a/runtimes/8.0/php.ini +++ b/runtimes/8.0/php.ini @@ -2,6 +2,7 @@ post_max_size = 100M upload_max_filesize = 100M variables_order = EGPCS +pcov.directory = . [opcache] opcache.enable_cli=1 diff --git a/runtimes/8.1/Dockerfile b/runtimes/8.1/Dockerfile index 746f3ecb..069107f7 100644 --- a/runtimes/8.1/Dockerfile +++ b/runtimes/8.1/Dockerfile @@ -16,7 +16,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt-get update \ && mkdir -p /etc/apt/keyrings \ - && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch \ + && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch ffmpeg \ && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null \ && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ && apt-get update \ diff --git a/runtimes/8.1/php.ini b/runtimes/8.1/php.ini index 39dcbcac..0320d71c 100644 --- a/runtimes/8.1/php.ini +++ b/runtimes/8.1/php.ini @@ -2,6 +2,7 @@ post_max_size = 100M upload_max_filesize = 100M variables_order = EGPCS +pcov.directory = . [opcache] opcache.enable_cli=1 diff --git a/runtimes/8.2/Dockerfile b/runtimes/8.2/Dockerfile index 3de361ef..ce30a399 100644 --- a/runtimes/8.2/Dockerfile +++ b/runtimes/8.2/Dockerfile @@ -16,7 +16,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt-get update \ && mkdir -p /etc/apt/keyrings \ - && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch \ + && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch ffmpeg \ && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \ && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ && apt-get update \ diff --git a/runtimes/8.2/php.ini b/runtimes/8.2/php.ini index 39dcbcac..0320d71c 100644 --- a/runtimes/8.2/php.ini +++ b/runtimes/8.2/php.ini @@ -2,6 +2,7 @@ post_max_size = 100M upload_max_filesize = 100M variables_order = EGPCS +pcov.directory = . [opcache] opcache.enable_cli=1 diff --git a/runtimes/8.3/Dockerfile b/runtimes/8.3/Dockerfile index a4fa8890..99670a25 100644 --- a/runtimes/8.3/Dockerfile +++ b/runtimes/8.3/Dockerfile @@ -16,7 +16,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt-get update \ && mkdir -p /etc/apt/keyrings \ - && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch \ + && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils librsvg2-bin fswatch ffmpeg \ && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \ && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ && apt-get update \ diff --git a/runtimes/8.3/php.ini b/runtimes/8.3/php.ini index 39dcbcac..0320d71c 100644 --- a/runtimes/8.3/php.ini +++ b/runtimes/8.3/php.ini @@ -2,6 +2,7 @@ post_max_size = 100M upload_max_filesize = 100M variables_order = EGPCS +pcov.directory = . [opcache] opcache.enable_cli=1 diff --git a/src/Console/AddCommand.php b/src/Console/AddCommand.php index ac88c598..09a0ab86 100644 --- a/src/Console/AddCommand.php +++ b/src/Console/AddCommand.php @@ -41,7 +41,7 @@ public function handle() } if ($invalidServices = array_diff($services, $this->services)) { - $this->error('Invalid services ['.implode(',', $invalidServices).'].'); + $this->components->error('Invalid services ['.implode(',', $invalidServices).'].'); return 1; } @@ -50,8 +50,9 @@ public function handle() $this->replaceEnvVariables($services); $this->configurePhpUnit(); - $this->info('Additional Sail services installed successfully.'); - $this->prepareInstallation($services); + + $this->output->writeln(''); + $this->components->info('Additional Sail services installed successfully.'); } } diff --git a/src/Console/Concerns/InteractsWithDockerComposeServices.php b/src/Console/Concerns/InteractsWithDockerComposeServices.php index 10974980..e52002f1 100644 --- a/src/Console/Concerns/InteractsWithDockerComposeServices.php +++ b/src/Console/Concerns/InteractsWithDockerComposeServices.php @@ -19,6 +19,7 @@ trait InteractsWithDockerComposeServices 'redis', 'memcached', 'meilisearch', + 'typesense', 'minio', 'mailpit', 'selenium', @@ -86,7 +87,7 @@ protected function buildDockerCompose(array $services) // Merge volumes... collect($services) ->filter(function ($service) { - return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'meilisearch', 'minio']); + return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'meilisearch', 'typesense', 'minio']); })->filter(function ($service) use ($compose) { return ! array_key_exists($service, $compose['volumes'] ?? []); })->each(function ($service) use (&$compose) { @@ -116,14 +117,35 @@ 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); + if (in_array('mysql', $services) || + in_array('mariadb', $services) || + in_array('pgsql', $services)) { + $defaults = [ + '# DB_HOST=127.0.0.1', + '# DB_PORT=3306', + '# DB_DATABASE=laravel', + '# DB_USERNAME=root', + '# DB_PASSWORD=', + ]; + + foreach ($defaults as $default) { + $environment = str_replace($default, substr($default, 2), $environment); + } + } + + if (in_array('mysql', $services)) { + $environment = preg_replace('/DB_CONNECTION=.*/', 'DB_CONNECTION=mysql', $environment); + $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=mysql", $environment); + }elseif (in_array('pgsql', $services)) { + $environment = preg_replace('/DB_CONNECTION=.*/', '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)) { + if ($this->laravel->config->has('database.connections.mariadb')) { + $environment = preg_replace('/DB_CONNECTION=.*/', 'DB_CONNECTION=mariadb', $environment); + } + $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); @@ -143,6 +165,14 @@ protected function replaceEnvVariables(array $services) $environment .= "\nMEILISEARCH_NO_ANALYTICS=false\n"; } + if (in_array('typesense', $services)) { + $environment .= "\nSCOUT_DRIVER=typesense"; + $environment .= "\nTYPESENSE_HOST=typesense"; + $environment .= "\nTYPESENSE_PORT=8108"; + $environment .= "\nTYPESENSE_PROTOCOL=http"; + $environment .= "\nTYPESENSE_API_KEY=xyz\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); @@ -170,6 +200,10 @@ protected function configurePhpUnit() { if (! file_exists($path = $this->laravel->basePath('phpunit.xml'))) { $path = $this->laravel->basePath('phpunit.xml.dist'); + + if (! file_exists($path)) { + return; + } } $phpunit = file_get_contents($path); @@ -218,22 +252,14 @@ protected function prepareInstallation($services) } if (count($services) > 0) { - $status = $this->runCommands([ + $this->runCommands([ './vendor/bin/sail pull '.implode(' ', $services), ]); - - if ($status === 0) { - $this->info('Sail images installed successfully.'); - } } - $status = $this->runCommands([ + $this->runCommands([ './vendor/bin/sail build', ]); - - if ($status === 0) { - $this->info('Sail build successful.'); - } } /** diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 87ca9847..5108f5e5 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -42,7 +42,7 @@ public function handle() } if ($invalidServices = array_diff($services, $this->services)) { - $this->error('Invalid services ['.implode(',', $invalidServices).'].'); + $this->components->error('Invalid services ['.implode(',', $invalidServices).'].'); return 1; } @@ -55,8 +55,21 @@ public function handle() $this->installDevContainer(); } - $this->info('Sail scaffolding installed successfully.'); - $this->prepareInstallation($services); + + $this->output->writeln(''); + $this->components->info('Sail scaffolding installed successfully. You may run your Docker containers using Sail\'s "up" command.'); + + $this->output->writeln('./vendor/bin/sail up'); + + if (in_array('mysql', $services) || + in_array('mariadb', $services) || + in_array('pgsql', $services)) { + $this->components->warn('A database service was installed. Run "artisan migrate" to prepare your database:'); + + $this->output->writeln('./vendor/bin/sail artisan migrate'); + } + + $this->output->writeln(''); } } diff --git a/stubs/docker-compose.stub b/stubs/docker-compose.stub index 55023b2c..9619b379 100644 --- a/stubs/docker-compose.stub +++ b/stubs/docker-compose.stub @@ -2,11 +2,11 @@ services: laravel.test: build: - context: ./vendor/laravel/sail/runtimes/8.2 + context: ./vendor/laravel/sail/runtimes/8.3 dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}' - image: sail-8.2/app + image: sail-8.3/app extra_hosts: - 'host.docker.internal:host-gateway' ports: diff --git a/stubs/typesense.stub b/stubs/typesense.stub new file mode 100644 index 00000000..dd3b8f44 --- /dev/null +++ b/stubs/typesense.stub @@ -0,0 +1,16 @@ +typesense: + image: 'typesense/typesense:0.25.2' + ports: + - '${FORWARD_TYPESENSE_PORT:-8108}:8108' + environment: + TYPESENSE_DATA_DIR: '${TYPESENSE_DATA_DIR:-/typesense-data}' + TYPESENSE_API_KEY: '${TYPESENSE_API_KEY:-xyz}' + TYPESENSE_ENABLE_CORS: '${TYPESENSE_ENABLE_CORS:-true}' + volumes: + - 'sail-typesense:/typesense-data' + networks: + - sail + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--spider", "http://localhost:8108/health"] + retries: 5 + timeout: 7s