Using docker override to ease your development
I didn't know you could this. What I normally do when I have a service that that has its own configuration for each environment, say for instance, web and web-dev, I run the separate service instance for each environment and tag each of them as seperate profiles. And, on .env file, i specify the profiles that I need.
But, dev workflow is always changing and you don't want to clutter your compose.yml file. Also, these two services aren't seperate instance, and they share mostly the same configuration. So, with override this is a lot cleaner.
So, the way I am using it right now is to have a production configuration in
compose.yml. And, whatever, I need for development, I put it in the
compose.override.yml. And, I also don't have it in the version control.
So, for example, this is one the web service in compose.yml
services:
web:
build: .
command: gunicorn config.wsgi:application --bind 0.0.0.0:${PORT:-4567}
restart: always
env_file:
- .env
ports:
- "${PORT:-4567}:${PORT:-4567}"
volumes:
- ${STATIC_ROOT}:/app/staticfiles
depends_on:
- db
And, this is the override in compose.override.yml
services:
web:
command: python manage.py runserver 0.0.0.0:8000
ports:
- "8000:8000"
volumes:
- .:/app