I have a docker-compose.yml
like that:
version: '2'
services:
backend:
build:
context: .
volumes:
- .:/home/ll/stuff
ports:
- '8000:80'
That always mounts the volume, what is nice for development, but not for production. Is there a way to »tell« docker-compose
to mount that volume only in development, or in other words, if APP_ENV
is empty or ==development
?
Do I need to create another compose file for that? If so, can I use the configuration from the production file, without repeating stuff that does not change?
From official docs: Modify your compose file for production
consider defining an additional Compose file, say production.yml, which specifies production-appropriate configuration. This configuration file only needs to include the changes you’d like to make from the original Compose file. The additional Compose file can be applied over the original docker-compose.yml to create a new configuration.
Once you’ve got a second configuration file, tell Compose to use it with the -f option:
docker-compose -f docker-compose.yml -f production.yml up -d
it should do the trick!