deployer icon indicating copy to clipboard operation
deployer copied to clipboard

[Symfony] Add dump-env task

Open richardhj opened this issue 1 year ago • 1 comments

Add task to run dump-env on deployment

  • [ ] Bug fix #…?

  • [x] New feature?

  • [ ] BC breaks?

  • [ ] Tests added?

  • [x] Docs added?

    Please, regenerate docs by running next command:
    $ php bin/docgen
    

As recommended on https://symfony.com/doc/current/deployment.html#b-configure-your-environment-variables

Run composer dump-env on every deployment.

The $APP_ENV shall be automatically when using set('dotenv', '{{deploy_path}}/shared/.env.local'); in the deploy.php file.

richardhj avatar Jun 30 '24 07:06 richardhj

Kindly request review from @garak @Tobion

richardhj avatar Jun 30 '24 07:06 richardhj

@richardhj Was it good idea? How can you do dump-env before composer install without symfony/flex ?

deploy:update_code
deploy:env
[development]  error  in symfony.php on line 69:
[development] run cd /www/hosting/xxxx/yyyy/releases/1 && (/usr/local/bin/composer dump-env "${APP_ENV:-prod}")
[development] err Command "dump-env" is not defined.
[development] exit code 1 (General error)
ERROR: Task deploy:env failed!

mrhackcz avatar Oct 22 '24 16:10 mrhackcz

@richardhj Was it good idea? How can you do dump-env before composer install without symfony/flex ?

dump-env is a symfony/flex utility - maybe that's the issue here?

richardhj avatar Oct 22 '24 16:10 richardhj

@richardhj Was it good idea? How can you do dump-env before composer install without symfony/flex ?

dump-env is a symfony/flex utility - maybe that's the issue here?

Yeah, but now, deploy:env in symfony.php is rewriting the default deploy:env in common.php. That now starts even before deploy:vendors which is installing symfony/flex.

mrhackcz avatar Oct 22 '24 16:10 mrhackcz

Ok, this is an ugly naming conflict that was unnoticed until now because the Symfony recipe in fact overrides the common.php's deploy task (if using the Symfony recipes, you would not use deploy:env by default).

richardhj avatar Oct 22 '24 16:10 richardhj

@richardhj Was it good idea? How can you do dump-env before composer install without symfony/flex ?

dump-env is a symfony/flex utility - maybe that's the issue here?

Yeah, but now, deploy:env in symfony.php is rewriting the default deploy:env in common.php. That now starts even before deploy:vendors which is installing symfony/flex.

Which is actually a problem for us: https://github.com/deployphp/deployer/discussions/3938

YetiCGN avatar Oct 23 '24 12:10 YetiCGN