From 2fc40e2804a06b9a6e5a3db4df1a40474708c9d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:12:26 +0000 Subject: [PATCH 1/7] chore: Update supported Platform.sh services --- local/platformsh/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local/platformsh/config.go b/local/platformsh/config.go index bb6b5402..b6de0118 100644 --- a/local/platformsh/config.go +++ b/local/platformsh/config.go @@ -79,7 +79,7 @@ var availablePHPExts = map[string][]string{ "opentelemetry": {"8.2", "8.3"}, "pdo": {"5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"}, "pdo_dblib": {"5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"}, - "pdo_firebird": {"5.4", "5.5", "5.6", "7.0", "7.1"}, + "pdo_firebird": {"5.4", "5.5", "5.6", "7.0", "7.1", "8.2", "8.3", "8.4"}, "pdo_mysql": {"5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"}, "pdo_odbc": {"5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"}, "pdo_pgsql": {"5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"}, From ee8dff26d4c76bd5ca1139f4479192ae98a1ec79 Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Wed, 8 Jan 2025 15:18:25 +0100 Subject: [PATCH 2/7] Updated the PHP `8.2.x` versions to the (current) PHP `8.4.x` in de `local:php:list` text output. --- commands/local_php_list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/local_php_list.go b/commands/local_php_list.go index f687596d..2583cdd5 100644 --- a/commands/local_php_list.go +++ b/commands/local_php_list.go @@ -88,7 +88,7 @@ var localPhpListCmd = &console.Command{ } terminal.Println("") - terminal.Println("To control the version used in a directory, create a .php-version file that contains the version number (e.g. 8.2 or 8.2.16),") + terminal.Println("To control the version used in a directory, create a .php-version file that contains the version number (e.g. 8.4 or 8.4.2),") terminal.Println("or define config.platform.php inside composer.json.") terminal.Println("If you're using Platform.sh or Upsun, the version can also be specified in their configuration files.") From 2a6bbfd8fdd586bc89063120c39a7fc7f25869be Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:12:39 +0000 Subject: [PATCH 3/7] chore: Update supported Platform.sh services --- local/platformsh/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local/platformsh/config.go b/local/platformsh/config.go index b6de0118..86e6ef7c 100644 --- a/local/platformsh/config.go +++ b/local/platformsh/config.go @@ -232,7 +232,7 @@ var availableServices = []*service{ Type: "rabbitmq", Versions: serviceVersions{ Deprecated: []string{"3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"}, - Supported: []string{"3.12", "3.13"}, + Supported: []string{"3.12", "3.13", "4.0"}, }, }, { From 42ca8b3794ede5e5b09df5a14a997eb6312b3e59 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:12:03 +0000 Subject: [PATCH 4/7] chore: Update supported Platform.sh services --- local/platformsh/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/local/platformsh/config.go b/local/platformsh/config.go index 86e6ef7c..e3392ad0 100644 --- a/local/platformsh/config.go +++ b/local/platformsh/config.go @@ -121,6 +121,7 @@ var availablePHPExts = map[string][]string{ "tidy": {"5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"}, "tokenizer": {"7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"}, "uuid": {"7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"}, + "uv": {"8.3"}, "wddx": {"7.0", "7.1", "7.2", "7.3", "7.4"}, "xcache": {"5.4", "5.5"}, "xdebug": {"5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"}, From 9c3ccd1b55292a6c63e5fea795d92f0223c99420 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Fri, 7 Feb 2025 12:08:17 +0100 Subject: [PATCH 5/7] fix: Fix Docker containers are not detected with Docker Desktop 4.38.0 This is due to a regression in Docker Desktop 4.38.0 making the API slow. We workaround this by defining a User Agent starting with "Docker-Client/" --- .github/workflows/releaser.yml | 2 +- commands/root.go | 3 +++ envs/docker.go | 21 ++++++++++++++++++--- envs/docker_version.go | 25 +++++++++++++++++++++++++ envs/generate_docker_version | 29 +++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 envs/docker_version.go create mode 100644 envs/generate_docker_version diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index 5f116172..9c3d11a2 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -42,7 +42,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') - name: Prepare - run: go generate ./ + run: go generate ./... - name: Check Git status id: git diff --git a/commands/root.go b/commands/root.go index 495e7014..cbe528e3 100644 --- a/commands/root.go +++ b/commands/root.go @@ -25,6 +25,7 @@ import ( "github.com/pkg/errors" "github.com/symfony-cli/console" + "github.com/symfony-cli/symfony-cli/envs" "github.com/symfony-cli/symfony-cli/local/platformsh" "github.com/symfony-cli/symfony-cli/reexec" "github.com/symfony-cli/symfony-cli/updater" @@ -99,6 +100,8 @@ func init() { } func InitAppFunc(c *console.Context) error { + envs.ComputeDockerUserAgent(c.App.Name, c.App.Version) + psh, err := platformsh.Get() if err != nil { return err diff --git a/envs/docker.go b/envs/docker.go index eb97e8f4..ddd34de7 100644 --- a/envs/docker.go +++ b/envs/docker.go @@ -19,6 +19,8 @@ package envs +//go:generate sh generate_docker_version + import ( "bytes" "context" @@ -44,8 +46,13 @@ import ( var ( dockerComposeNormalizeRegexp = regexp.MustCompile("[^-_a-z0-9]") dockerComposeNormalizeRegexpLegacy = regexp.MustCompile("[^a-z0-9]") + dockerUserAgent = "Docker-Client/unknown version" ) +func ComputeDockerUserAgent(appName, appVersion string) { + dockerUserAgent = fmt.Sprintf("Docker-Client/%s %s/%s", dockerClientVersion, appName, appVersion) +} + type sortedPorts []types.Port func (ps sortedPorts) Len() int { return len(ps) } @@ -71,7 +78,17 @@ func (l *Local) RelationshipsFromDocker() Relationships { return nil } - client, err := docker.NewClientWithOpts(docker.WithTimeout(2*time.Second), docker.FromEnv, dockerUseDesktopSocketIfAvailable) + client, err := docker.NewClientWithOpts( + docker.FromEnv, + dockerUseDesktopSocketIfAvailable, + docker.WithAPIVersionNegotiation(), + // we use a short timeout here because we don't want to impact + // negatively performance when Docker is not reachable + docker.WithTimeout(2*time.Second), + // defining a User Agent to avoid having the Docker API being slow + // see https://github.com/docker/for-mac/issues/7575 + docker.WithUserAgent(dockerUserAgent), + ) if err != nil { if l.Debug { fmt.Fprintf(os.Stderr, "ERROR: %s\n", err) @@ -80,8 +97,6 @@ func (l *Local) RelationshipsFromDocker() Relationships { } defer client.Close() - client.NegotiateAPIVersion(context.Background()) - containers, err := client.ContainerList(context.Background(), container.ListOptions{}) if err != nil { if docker.IsErrConnectionFailed(err) { diff --git a/envs/docker_version.go b/envs/docker_version.go new file mode 100644 index 00000000..6713f4ce --- /dev/null +++ b/envs/docker_version.go @@ -0,0 +1,25 @@ +// Code generated by envs/generate_docker_version +// DO NOT EDIT + +/* + * Copyright (c) 2021-present Fabien Potencier + * + * This file is part of Symfony CLI project + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package envs + +const dockerClientVersion = "v27.3.1" diff --git a/envs/generate_docker_version b/envs/generate_docker_version new file mode 100644 index 00000000..b5b42fb7 --- /dev/null +++ b/envs/generate_docker_version @@ -0,0 +1,29 @@ +#!/usr/bin/env sh + +cat < docker_version.go +// Code generated by envs/generate_docker_version +// DO NOT EDIT + +/* + * Copyright (c) 2021-present Fabien Potencier + * + * This file is part of Symfony CLI project + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package envs + +const dockerClientVersion = "$(go list -m all | grep github.com/docker/docker | awk -F '[ +]' '{print $2}')" +EOF From e7cd994f7ebb29ae9abc1ceb16518617858fd8a6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 7 Feb 2025 16:56:15 +0100 Subject: [PATCH 6/7] Bump pm.max_children from 5 to 100 --- local/php/fpm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local/php/fpm.go b/local/php/fpm.go index 364c8c63..b1092d24 100644 --- a/local/php/fpm.go +++ b/local/php/fpm.go @@ -92,7 +92,7 @@ daemonize = no listen = %s listen.allowed_clients = 127.0.0.1 pm = dynamic -pm.max_children = 5 +pm.max_children = 30 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 From e3b7acc635dc8416a2e1ceecf0940c5d2f269410 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 7 Feb 2025 18:38:40 +0100 Subject: [PATCH 7/7] Update fixtures --- commands/testdata/project/.platform.app.yaml | 5 ++++- commands/testdata/project/.upsun/config.yaml | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/commands/testdata/project/.platform.app.yaml b/commands/testdata/project/.platform.app.yaml index da867bc4..84e0accc 100644 --- a/commands/testdata/project/.platform.app.yaml +++ b/commands/testdata/project/.platform.app.yaml @@ -34,7 +34,7 @@ web: passthru: "/index.php" mounts: - "/var": { source: local, source_path: var } + "/var/cache": { source: local, source_path: var/cache } relationships: @@ -60,5 +60,8 @@ crons: # Check that no security issues have been found for PHP packages deployed in production spec: '50 23 * * *' cmd: if [ "$PLATFORM_ENVIRONMENT_TYPE" = "production" ]; then croncape COMPOSER_ROOT_VERSION=1.0.0 COMPOSER_AUDIT_ABANDONED=ignore composer audit --no-cache; fi + clean-expired-sessions: + spec: '17,47 * * * *' + cmd: croncape php-session-clean diff --git a/commands/testdata/project/.upsun/config.yaml b/commands/testdata/project/.upsun/config.yaml index dfccafe6..c1e767bc 100644 --- a/commands/testdata/project/.upsun/config.yaml +++ b/commands/testdata/project/.upsun/config.yaml @@ -73,5 +73,8 @@ applications: # Check that no security issues have been found for PHP packages deployed in production spec: '50 23 * * *' cmd: if [ "$PLATFORM_ENVIRONMENT_TYPE" = "production" ]; then croncape COMPOSER_ROOT_VERSION=1.0.0 COMPOSER_AUDIT_ABANDONED=ignore composer audit --no-cache; fi + clean-expired-sessions: + spec: '17,47 * * * *' + cmd: croncape php-session-clean