0

I'm trying to perform Continuous Deployment with Github and Laravel 5. I want to create 3 branch in my Git, develop, QA, and master A push in each respective branch would deploy in a different server, all instances of AWS Amazon EC2.

Thing is I don't know how to manage .env file for instance. For those 3 servers, this file should be different. Besides, this file is part of .gitignore, so it will not be deployed. So how should I do to manage this part???

2 Answers 2

1

The first time you setup your hosting, you clone the corresponding branch into your server. Then you write manually the .env file.

When your server will clone revisions after that, your .env will stay untouched because it is gitignore'd.

That's the whole point of using a .env in the first time: set configuration by install independently of versionning.

If you still want to make your .env part of the versionned code, but still keep sensitive data out of your repository, I suggest using env variables to store that data.

To use a env variable from a .env file, use YOUR_CONF={$YOUR_ENV_VAR} in your .env file. Make sure YOUR_ENV_VAR is set on your server env.

Hope it's more clear now.

Also on a side note, maybe you should consider using a PhpCi install to help you acheive that.

Sign up to request clarification or add additional context in comments.

3 Comments

Well that's all the point of that. I m using Continuous Deployement, and I always deploy a full project clone, so I will never have .env.
That's not how it is supposed to work. As stated by the docs, laravel's .env must stay consistent across deployments (it is server specific). Another way is to setup server env variables and use them to hold your data. But you'll still need a .env (but it can be versionned because all credentials can be move to env variables).
Exact, I will use a standart .env without data, and relation it to server variables
0

Solution would be setting global variable $_ENV in server to each environement!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.