Skip to content

Conversation

@chirimoya
Copy link
Contributor

@chirimoya chirimoya commented Sep 9, 2025

This pull request introduces initial support for creating new Sulu projects using the Symfony CLI.

e.g. symfony new my-project --sulu symfony new my-project --skeleton=sulu

@chirimoya
Copy link
Contributor Author

@nicolas-grekas one question just to make sure I understood the code correctly that handles template selection for the cloud configuration: I need to contribute a new Sulu template to https://github.com/symfonycorp/cloud-templates in the upsun/ directory (e.g. upsun/sulu.yaml), so that it is automatically matched by the has_composer_package requirement in the YAML template, correct? Also, what would be the best way to test it before merging?

@tucksaun
Copy link
Member

Because this might open the possibility to use others skeletons I would instead go with a string flag to specify the skeleton repository to use. This would let the user specify any repo and we could add some shortcut as symfony or sulu. The default value would be symfony.
For sulu usage this would mean a symfony new --skeleton=sulu my-project

WDYT?

@tucksaun
Copy link
Member

I need to contribute a new Sulu template to https://github.com/symfonycorp/cloud-templates in the upsun/ directory (e.g. upsun/sulu.yaml), so that it is automatically matched by the has_composer_package requirement in the YAML template, correct?

Correct but only if you need specifics. If you don't the generic Symfony template might be sufficient

Also, what would be the best way to test it before merging?

If you are ok with building the CLI locally, you can edit github.com/symfony-cli/symfony-cli/commands.templatesGitRepository constant and change the value with your fork instead.

@chirimoya chirimoya force-pushed the feature/symfony-cli-sulu-support branch from 1cdab05 to 032ba36 Compare September 19, 2025 14:16
@chirimoya
Copy link
Contributor Author

chirimoya commented Sep 19, 2025

For sulu usage this would mean a symfony new --skeleton=sulu my-project

@tucksaun thanks for your feedback! I’ve refactored the code according to your suggestions.

In the meantime, I’ve figured out how to test the upsun templates and forked the template repository (https://github.com/chirimoya/cloud-templates/tree/feature/sulu-upsun-template/upsun). So far it looks good, but I’m running into some challenges with the template definition and could use some input:

  • We normally use MySQL, but the Docker Compose detection of services and their mapping to upsun services doesn’t seem to work with MySQL. I’m not sure how to fix that.
  • We’d like to set up a proper production configuration that also includes Varnish, but I’m facing a couple of issues:

Any suggestions on how to solve these issues? /cc @nicolas-grekas

@chirimoya chirimoya force-pushed the feature/symfony-cli-sulu-support branch from 032ba36 to 8e1eaf0 Compare September 19, 2025 14:44
@tucksaun
Copy link
Member

  • We normally use MySQL, but the Docker Compose detection of services and their mapping to upsun services doesn’t seem to work with MySQL. I’m not sure how to fix that.

You might need to debug what parseCloudServices is returning (you can use dumper.Dump to start introspecting it)

IIRC on SymfonyCloud one trick that was working was to use a "public" URL but protected with credentials.

@chirimoya
Copy link
Contributor Author

  • How can we combine the Docker Compose detection with predefined services?

@tucksaun ... do you have any suggestions on how to solve this issue? By “predefined services,” I am referring to Varnish. Most projects I know don’t use Varnish for local development, but we highly recommend it for production.

@tucksaun
Copy link
Member

@chirimoya I'm not sure to understand your question because if I got it correctly by “predefined services” you are mostly referring to Varnish in production, but in such case the CLI is out of its scope here and won't be in use, so no interaction with “predefined services” whatsoever 🤔

@chirimoya
Copy link
Contributor Author

chirimoya commented Sep 25, 2025

@tucksaun ... by “predefined services” I’m referring to the cloudServices used during the upsun project initialization. They are parsed either from the CLI or from the Docker file within the parseCloudServices. The question is whether we can define additional services somewhere, e.g. Varnish for a Sulu project?

@chirimoya chirimoya marked this pull request as draft October 1, 2025 15:57
@chirimoya chirimoya changed the title [WIP] Add Symfony CLI support for bootstrapping Sulu projects Add Symfony CLI support for bootstrapping Sulu projects Oct 1, 2025
@chirimoya chirimoya marked this pull request as ready for review October 1, 2025 16:00
@chirimoya chirimoya force-pushed the feature/symfony-cli-sulu-support branch 2 times, most recently from 33df8dc to e563228 Compare October 2, 2025 12:11
Copy link
Contributor

@fabpot fabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me.
I'd like to better understand Oracle MySQL support here though.

} else if strings.Contains(strings.ToLower(service.Image), "mysql") {
dbType = "oracle-mysql"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this part. Can you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous implementation was not able to distinguish between MariaDB and MySQL because only the port was taken into consideration. And it’s connected to how Upsun handles MariaDB/MySQL: https://docs.upsun.com/add-services/mysql.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may also need to mention this to make the changes clearer: handling service types like oracle-mysql and redis-persistent in upsun required adding the Endpoint property to the CloudService struct, since the endpoint does not match the service type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be else if strings.Contains(strings.ToLower(service.Image), "oracle-mysql") { then here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so. This method is about parsing the Docker compose.yaml file and finding the matching upsun services. The Docker image name for Oracle MySQL is mysql. The matching service name on upsun is oracle-mysql. I know it's quite confusing. See https://docs.upsun.com/add-services/mysql.html

Until now, only the port was taken into consideration. So everything matching port 3306 was defined as upsun service mysql. But mysql within upsun actually refers to mariadb. Especially with the version section, things got a bit messy. In our case, it tried to interpret the service as MariaDB with version 8.0 of MySQL. I hope my fix will improve the mapping from Docker to upsun.

@chirimoya chirimoya force-pushed the feature/symfony-cli-sulu-support branch 2 times, most recently from ae27471 to ca330fa Compare October 16, 2025 08:04
@chirimoya
Copy link
Contributor Author

@tucksaun @fabpot ... any idea why the pipeline is failing? I’m not sure which change caused it. Any suggestions?

@fabpot
Copy link
Contributor

fabpot commented Oct 17, 2025

@tucksaun @fabpot ... any idea why the pipeline is failing? I’m not sure which change caused it. Any suggestions?

Nothing you can do, it's a BC break upstream: platformsh/platformsh-docs#5067 (comment)

@nicolas-grekas
Copy link
Contributor

PR unlocked by merging symfonycorp/cloud-templates#43

@fabpot fabpot force-pushed the feature/symfony-cli-sulu-support branch from ca330fa to 61f7d22 Compare November 8, 2025 10:13
@fabpot
Copy link
Contributor

fabpot commented Nov 8, 2025

Thank you @chirimoya.

@fabpot fabpot merged commit afef23c into symfony-cli:main Nov 8, 2025
2 checks passed
@chirimoya
Copy link
Contributor Author

@fabpot Thanks!

@chirimoya chirimoya deleted the feature/symfony-cli-sulu-support branch November 10, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants