Deploy in production with Symfony Flex and --no-dev

I have several major Symfony projects, and I noticed that after upgrading everything to Symfony 4 (Flex), when our deployment automation performs its usual process:

composer install --no-dev

As a result, we get (for example):

 Symfony operations: 2 recipes (72fad9713126cf1479bb25a53d64d744) - Unconfiguring symfony/maker-bundle (>=1.0): From github.com/symfony/recipes:master - Unconfiguring phpunit/phpunit (>=4.7): From github.com/symfony/recipes:master 

Then, as expected, this leads to changes in symfony.lock and config/bundles.php , plus everything else, depending on what was included in require-dev in composer.json .

None of this breaks down, for sure, but annoying the existence of a production rollout that no longer has a clean output of git status , and can lead to confusion about what is actually deployed.

There are various workarounds for this, for example, I could just put everything in require rather than require-dev , since there is no real harm when deploying this stuff, or I could omit the --no-dev of the Composer command.

But really, what is the right practice here? It seems strange that there is no way to tell Flex not to make any configuration changes if you are just deploying a blocked piece of software. Is this a function request, or am I missing some configuration here?

+8
symfony composer-php symfony4 symfony-flex
source share
1 answer

When deploying to prod from the main branch, you can configure the deployment branch. And in this thread you can prohibit the merging of certain files. See this post for more details . This creates a situation where you have a master branch, a version branch (example: 3.21.2), and you have a report validation wizard, work on it, and then merge their changes into a version branch. From there you choose what will be deployed to prod. (There will be a slight balancing effect. You will want to merge all the dev changes into master until it matches your version branch, and make sure the wizard matches the version after deployment. This adds a bit of work and you should keep track of it, etc. )

Another option is to separate the git repository from the deployment directory. In this example , the git directory is created in /var/repo/site.git , and the deployment directory /var/www/domain.com and the git hook post-reception are used to automatically update the www directory after the push is received in the repo / site directory . You obviously use the composer, npm, gulp, whathaveyou in the www directory, and the git directory remains as it is.

Without going into commercial options such as continuous deployment applications, you can write a deployment script. There are many ways to write a shell script that takes one directory and copies it, starts the composer, starts npm, etc. All in one command - sharing your git with your deployment directories. Here's a simple one that uses the current time-time to name the directory, and then symbolically bind it to the deployment directory.

0
source share

All Articles