Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Symfony] Add dump-env task #3856

Merged
merged 4 commits into from
Oct 3, 2024
Merged

[Symfony] Add dump-env task #3856

merged 4 commits into from
Oct 3, 2024

Conversation

richardhj
Copy link
Contributor

@richardhj richardhj commented Jun 30, 2024

Add task to run dump-env on deployment

  • Bug fix #…?

  • New feature?

  • BC breaks?

  • Tests added?

  • 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.

Add task to run dump-env on deployment
@richardhj
Copy link
Contributor Author

Kindly request review from @garak @Tobion

run('{{bin/composer}} dump-env "${APP_ENV:-prod}"');
});
});

desc('Deploys project');
task('deploy', [
Copy link

Choose a reason for hiding this comment

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

If you want to dump env on every deployment, you should add it to the deploy task?

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 do it in my project :) But it's nothing for the recipe IMHO

@antonmedv antonmedv merged commit 70e27b4 into deployphp:master Oct 3, 2024
9 checks passed
@richardhj richardhj deleted the patch-2 branch October 3, 2024 15:41
@mrhackcz
Copy link
Contributor

@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!

@richardhj
Copy link
Contributor Author

@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?

@mrhackcz
Copy link
Contributor

@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.

@richardhj
Copy link
Contributor Author

richardhj commented Oct 22, 2024

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).

@YetiCGN
Copy link

YetiCGN commented Oct 23, 2024

@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: #3938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants