EasyCorp / easy-deploy-bundle

The easiest way to deploy your Symfony applications
https://easycorp.io/EasyDeploy
MIT License
473 stars 103 forks source link

Composer install --no-dev failing with sf4 + flex #35

Open djamadeus opened 6 years ago

djamadeus commented 6 years ago

I fixed this here, https://github.com/EasyCorp/easy-deploy-bundle/commit/45da26d38d1281ea9ff201bfaa03e854fbb5f64a

messed up the fork though, so can't create clean pullrequest (or at least I dunno know how)

To make it nice you would replace the 'prod' with the symfony-env

djamadeus commented 6 years ago

this one hast it cleaner: https://github.com/Wunderdata/easy-deploy-bundle-wunderfork/commit/35a3a31325e84d9e961723ab2779ab6df468add0

zorn-v commented 6 years ago

It is not bundle problem. You can move symfony/dotenv from dev deps in composer.json, or just set env vars properly. http://symfony.com/doc/current/best_practices/configuration.html

djamadeus commented 6 years ago

yep but you still have pass app_env manually to the "composer install"-call, otherwise the call will fail with "symfony-cmd handling the auto-scripts event returned with error code 127"

zorn-v commented 6 years ago

You can set it (and other vars like APP_DEBUG) in ~/.profile or ~/.bashrc for user which doing deploy for example export APP_ENV=prod Or just

set -a
. /path/to/project/.env
set +a

https://unix.stackexchange.com/questions/79064/how-to-export-variables-from-a-file

djamadeus commented 6 years ago

Yep true, thanks for the hint. I'm switching between prod and debug on staging server though, so adding this directly to import command, using value from symfony env, still makes sense for me, (and keeps config in one place centralized, and makes composer use the env chosen in deploy-config, regardless from server config) but I agree, this is no bug/issue of the module then.

Am 06.12.2017 00:59 schrieb "zorn-v" notifications@github.com:

You can set it (and other vars like APP_DEBUG) in ~/.profile or ~/.bashrc for user which doing deploy for example export APP_ENV=prod Or just

set -a. /path/to/project/.envset +a

https://unix.stackexchange.com/questions/79064/how-to- export-variables-from-a-file

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EasyCorp/easy-deploy-bundle/issues/35#issuecomment-349482489, or mute the thread https://github.com/notifications/unsubscribe-auth/AE3dLrUQ-s5bCYb4XpbDrFgCFnPs435eks5s9djHgaJpZM4QzK8D .

bzoks commented 6 years ago

AbstractDeployer actually sets variable SYMFONY_ENV to provided ->symfonyEnvironment(), which is later used in commands: [xxx@server.com] Executing command: (export SYMFONY_ENV=staging; cd /usr/local/www/... but this environment variable has no meaning in Symfony4 - code should set APP_ENV instead when run on version 4.

cve commented 6 years ago

I also have problems with Symfony 4 and .env file

Unable to read the "[...]/releases/20180208192107/bin/../.env" environment file.
MSDATDE commented 6 years ago

@cve Have you found the solution to this problem? I have the same problem with Symfony 4.

cve commented 6 years ago

@MSDATDE not yet

cve commented 6 years ago

Does anyone has an example how to using this bundle with Symfony 4?

deantomasevic commented 5 years ago

Hi,

i had the same error:

  Generating autoload files
  Executing script cache:clear [KO]
   [KO]
  Script cache:clear returned with error code 255
  !!  PHP Fatal error:  Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "/var/www/domain/releases/20190126225728/.env" environment file. in /var/www/domain/releases/20190126225728/vendor
  /symfony/dotenv/Dotenv.php:466
  !!  Stack trace:

The main problem is: https://symfony.com/doc/current/configuration/dot-env-changes.html

B) The .env file is now commited to your repository. It was previously ignored via the .gitignore file (the updated recipe does not ignore this file). Because this file is committed, it should contain non-sensitive, default values. Basically, the .env.dist file was moved to .env.

FIX: https://github.com/EasyCorp/easy-deploy-bundle/pull/86

bin/console deploy staging
Initializing configuration
Starting the deployment
Updating app code
Preparing app
Optimizing app
Publishing app
Finishing the deployment
[OK] Deployment was successful
PtrTn commented 5 years ago

I ran into the same issue. Since #86 has not been merged yet I solved it by adding a command to the beforePreparing() hook as such:

public function beforePreparing()
{
   $this->runRemote(sprintf('cp {{ deploy_dir }}/repo/.env {{ project_dir }} 2>/dev/null'));
}
COil commented 4 years ago

@PtrTn I have made the same but still having an error afer composer install:

[KO]
  Script cache:clear returned with error code 1
  !!
  !!  In EnvVarProcessor.php line 162:
  !!
  !!    Environment variable not found: "APP_SERVER".

If I interrupt the deployment just at this step and run the same command manually, it works. I have added the ENV var in .bashrc, so they are defined:

[21:51:04] root@vps:/var/www-deploy/site.com/releases/20191129214947# printenv | grep -i app
APP_SECRET=whatever
APP_DEBUG=0
APP_ENV=prod
APP_SERVER=prod