1

I'm using Laravel 5.4, Envoyer and Forge. Every time I deploy master branch on Envoyer, my .env file gets deleted. It has no content.

What should I do? Is it maybe my configuration faulty?

Miha Vidakovic
  • 393
  • 1
  • 4
  • 13
  • Not seen this before. I use forge for everything. Are you configuring the .env inside forge? Obviously it doesn't get deployed when you push to master – Andy Holmes Apr 07 '17 at 19:30
  • I'm not configuring it inside forge, but when I deploy master it gets deleted and then I need to configure it on forge... – Miha Vidakovic Apr 07 '17 at 19:32
  • Then I would use Forge to set your .env. Go into the site on the Forge UI, scroll to the bottom, Edit Files, Edit Environment File – Andy Holmes Apr 07 '17 at 19:34
  • I do that, but then again when I deploy master - it gets empty... – Miha Vidakovic Apr 07 '17 at 19:53
  • Deploying via forge doesn't touch the .env files though for security. I don't know what to suggest – Andy Holmes Apr 07 '17 at 21:16
  • By default .env is ignored in .gitignore file. You need to delete it there and then it won't be deleted when you deploy – lewis4u Apr 07 '17 at 22:06
  • Make sure you have added .env file in your git on the first place and it is keeping a track of it while making the new commit. – Saquib Lari Aug 26 '17 at 11:36

2 Answers2

4

Let's breakdown the way Envoyer works:

  1. Clones the git repository to a new release folder - found under /releases.
  2. Runs composer install on this new cloned directory (to bring your vendor folder up to date).
  3. Overwrites the symlink for /path/to/project/current from /path/to/project/releases/[first release folder] to /path/to/project/releases/[second release folder.
  4. Clears out old release folders.

When a new version is deployed, it does a fresh clone of the git repository. Unless you have changed your .gitignore, your .env file is NOT tracked in git so is never in the new folder.

By using the environment capability built-in to Envoyer, this places an .env file here /path/to/project/.env and symlinks from /path/to/project/.env to /path/to/project/current/.env.

DanTheDJ1
  • 300
  • 2
  • 8
1

The proper way with your setup would be to set env variables with Manage Environment at envoyer. There is a laracast episode on this topic - https://laracasts.com/series/envoyer/episodes/9

enter image description here

lchachurski
  • 1,770
  • 16
  • 21