Skip to content

Commit

Permalink
update upstream from Sail (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepg authored Feb 23, 2024
1 parent 82264b2 commit 3316197
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 67 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/1_Bug_report.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
28 changes: 1 addition & 27 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 29 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
18 changes: 12 additions & 6 deletions bin/sail
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion runtimes/8.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions runtimes/8.0/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS
pcov.directory = .

[opcache]
opcache.enable_cli=1
2 changes: 1 addition & 1 deletion runtimes/8.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions runtimes/8.1/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS
pcov.directory = .

[opcache]
opcache.enable_cli=1
2 changes: 1 addition & 1 deletion runtimes/8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions runtimes/8.2/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS
pcov.directory = .

[opcache]
opcache.enable_cli=1
2 changes: 1 addition & 1 deletion runtimes/8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions runtimes/8.3/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS
pcov.directory = .

[opcache]
opcache.enable_cli=1
7 changes: 4 additions & 3 deletions src/Console/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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.');
}
}
56 changes: 41 additions & 15 deletions src/Console/Concerns/InteractsWithDockerComposeServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ trait InteractsWithDockerComposeServices
'redis',
'memcached',
'meilisearch',
'typesense',
'minio',
'mailpit',
'selenium',
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.');
}
}

/**
Expand Down
19 changes: 16 additions & 3 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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('<fg=gray>➜</> <options=bold>./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('<fg=gray>➜</> <options=bold>./vendor/bin/sail artisan migrate</>');
}

$this->output->writeln('');
}
}
4 changes: 2 additions & 2 deletions stubs/docker-compose.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 3316197

Please sign in to comment.