dreamfactorysoftware / df-docker

Docker container for DreamFactory.
59 stars 56 forks source link

Make .env configs environment variable based #23

Closed philicious closed 8 years ago

philicious commented 8 years ago

This PR enables the df-docker image to be configurable via environment variables which makes it possible to use the same image for different installations/environments (prod, staging..) and for using an external MySQL db aswell as a linked mysql container. And using Redis as cache or not. It doesnt matter, the image stays the same.

Its also very helpful to use it via docker-compose like so

DB_HOST=mysql.acme.com
DB_USERNAME=df_admin
DB_PASSWORD=foobar
DB_DATABASE=df2
REDIS_HOST=redis.acme.com
REDIS_DATABASE=0
APP_KEY=super_secret

or by passing the env vars via docker run.... -e DB_HOST=mysql.acme.com etc.. or using the image with a docker orchestrator like mesos/kubernetes/AWS ECS/etc

There are more configs (memcache..) that could be set like this but as we dont need them, I havent added them. But my changes give everyone enough of an idea on how to add them easily.

If no APP_KEY is passed in, a new one is generated.

PS: I know there is php artisan dreamfactory:setup command which could be used instead of sed but "my approach" gives one better control over whats really going on in a container and a basic dreamfactory:setup run is already done in the Dockerfile = resulting image.