Laravel comes by default with a .env
file that comes under the root folder when you create a new project. I am having a fresh Laravel installation with this folder structure
root/
├── docker/
│ ├── php/
│ │ ├── Dockerfile
│ └── nginx/
│ | ├── Dockerfile
│ | └── default.conf
| |__ webapp.env
├── Laravel/
│ ├── app/
│ ├── bootstrap/
│ ├── config/
│ ├── database/
│ ├── public/
│ ├── resources/
│ ├── routes/
│ ├── storage/
│ ├── tests/
│ ├── vendor/
│ ├── artisan
│ ├── composer.json
│ ├── composer.lock
│ └── README.md
| |__ .env
└── docker-compose.yml
And this is how I am referencing both at the moment in the docker-compose.yml
...
env_file:
- "docker/webapp.env"
- "laravel/.env"
As you can see I have a webapp.env
inside the docker folder, in which I am keeping any environment variables required for the Docker images I am using.
At the moment it is a bit hard to manage the environment variables as I need to jump from one file or another etc, so I was wondering whether it is possible to copy all the env variables from the .env file to my webapp.env
and point Laravel to use this file instead of the default one?
2
Answers
You can move all the env variables with
and then create symlink
I’m not sure this approach works,( without testing). We used this to map other files/folders into the project. It is the same theory you can use, too
This will map all the items in
webapp.env
to.env
on the docker build.