Open wcizmowski opened 5 years ago
In src/Deployer/DefaultDeployer.php:264
change $this->runRemote(sprintf('cp -RPp {{ deploy_dir }}/repo/* {{ project_dir }}'));
to $this->runRemote(sprintf('cp -RPp {{ deploy_dir }}/repo/. {{ project_dir }}'));
this will 'cp' all files including the hidden .env
. Hope that helps. If you are using Symfony 4.2, there might be some more steps to do. Just comment if you run into any other issues.
Also, since you're deploying to prod you should move composer require symfony/dotenv
from require-dev
to require
in your composer.json
I confirm that changing /repo/*
to /repo/.
works for Symfony 4.2.
I've hit this problem too. A note is by doing the change in the repo copy it's going to copy the full .git directory over too. Instead since often you don't want all your dotfiles copied it'd be better to use beforePreparing:
public function beforePreparing()
{
$this->log('<h3>Copying over the .env files</>');
$this->runRemote('cp {{ deploy_dir }}/repo/.env {{ project_dir }}');
}
the /release directory doesn't contain .env file while /repo dir has this .env file
Could I please describe this issue in documentation? I confused about best practices of managing .env when I using this bundle.
I was trying
// run some local or remote commands before the deployment is started
public function beforeStartingDeploy()
{
$this
->runLocal('./vendor/bin/simple-phpunit --env=dev');
}
and
// run some local or remote commands before the deployment is started
public function beforeStartingDeploy()
{
$this
->symfonyEnvironment('dev')
->runLocal('./vendor/bin/simple-phpunit');
}
But both does not works. In case of default config
public function beforeStartingDeploy()
{
$this
->runLocal('./vendor/bin/simple-phpunit');
}
I obtaining
The command "(export APP_ENV=prod; cd /home/daniel/pro/pregnacore/core && ./vendor/bin/simple-ph
punit --env=dev)" failed.
Because of APP_ENV
should be dev
not prod
locally during testing. Because I have test in dev
requirements.
This works for me.
public function **beforeUpdating**() { $this->runRemote('cp {{ deploy_dir }}/repo/.env {{ project_dir }}'); parent::beforeUpdating(); }
Hi,
On my side I prefer :
public function beforePreparing() { $this->log('<h3>Copying over the .env files</>'); $this->runRemote('cp {{ deploy_dir }}/repo/.env.dist {{ project_dir }}/.env'); }
For Symfony 4.3 it should be copy .env to .env.local
On Wed, Jul 17, 2019, 2:44 PM Nicolas Guillard notifications@github.com wrote:
Hi,
On my side I prefer :
public function beforePreparing() { $this->log('
Copying over the .env files</>'); $this->runRemote('cp {{ deploy_dir }}/repo/.env.dist {{ project_dir }}/.env'); }
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EasyCorp/easy-deploy-bundle/issues/87?email_source=notifications&email_token=AKMP3X5HWWYVCTWI5O7EGE3P74H4NA5CNFSM4GTAYAKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2ECEDQ#issuecomment-512238094, or mute the thread https://github.com/notifications/unsubscribe-auth/AKMP3XZJ7GYINMMFOCHDUATP74H4NANCNFSM4GTAYAKA .
The deploy script don't seems to copy dot files on project root folder, is that only for me ?
I also faced this issue.
As a workaround, I put the .env and .env.local file as shared file.
->sharedFilesAndDirs(['.env','.env.local'])
The drawback is that you now have to handle manually the change in your .env file as it won't be synchronized with your repo, but anyway you would have to edit your .env.local file. No big deal.
Hello, I have also to put the .env as a shared file. Check out https://stackoverflow.com/q/59111354/633864, in fact I don't need to use env vars as my application only relies on .env files. Do you think I would be ok to introduce a new parameter to see if the APP_ENV env should be set?
Using Symfony 5 with PHP 7.4, this PR https://github.com/EasyCorp/easy-deploy-bundle/pull/114 fixes that issue.
I thought we shouldn't commit any secrets in .env
? If that the case we have to manual copy paste our .env.local.php
each time we deploy and not relying on the .env
from git.
Hi,
I have $this->runRemote('export SYMFONY_ENV=prod');
but uppon deploy error
PHP Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "/var/www/vhosts/iwebi.pl/app-s4.iwebi.pl/releases/20190129153613/.env" environment file. in /var/www/vhosts/iwebi.pl/app-s4.iwebi.pl/releases/20190129153613/vendor/symfony/dotenv/Dotenv.php:466
butr