DEV Community 👩‍💻👨‍💻

Discussion on: docker-compose up your entire Laravel + Apache + MySQL development environment.

veevidify profile image
V Author • Edited on

Right, so what .env essentially does is that it emulates Laravel reading the actual runtime environment variables. In other words Laravel treats .env variables as if they're your actual host or build context's environment variables. Conveniently for us, docker-compose is also able to read from .env.

So to put it clearly, both Laravel and docker read these variables in a build context, which are mocked by .env file for development purposes.

In your deployment / build context, you would want to export these variables too. To name a few, Gitlab CI allows configuring them under Settings > CI/CD. Circle CI does also, under Build Settings > Environment Variables. If you only deploy from local (instead of remote CI), simply run deployment from within a container built with .env variables exported.