Improve Docker and Docker Compose files
Hey there,
it took me a while to understand the architecture of mediacms. The setup-guide was not working for me in the beginning.
I had to set ENABLE_UWSGI to yesby uncommenting it. Otherwise I got a Bad Gateway from the nginx proxy.
I also removed postgres as I use a productive database hosted on a different machine.
for volumes, I only mount logs, media and the deploy-directory, as it contains configuration details.
I would not recommend mount the whole git-repo, as you overwrite the containers code, which makes no sense IMHO.
Also, making the settings.py readonly will lead into error:
mediacms-migrations-1 | chown: changing ownership of '/home/mediacms.io/mediacms/cms/settings.py': Read-only file system
When using config-maps in kubernetes i.e., a read-only settings-file would be mandatory.
Maybe change to a yaml file and use pyyaml to manage it. I do this on my python projects aswell.
version: "3"
services:
redis:
image: "redis:alpine"
restart: always
healthcheck:
test: ["CMD", "redis-cli","ping"]
interval: 30s
timeout: 10s
retries: 3
migrations:
image: mediacms/mediacms:latest
volumes:
- /mnt/mediacms/deploy:/home/mediacms.io/mediacms/deploy
- /mnt/mediacms/logs:/home/mediacms.io/mediacms/logs
- /mnt/mediacms/media_files:/home/mediacms.io/mediacms/media_files
- /mnt/mediacms/settings.py:/home/mediacms.io/mediacms/cms/settings.py
environment:
ENABLE_UWSGI: 'no'
ENABLE_NGINX: 'no'
ENABLE_CELERY_SHORT: 'no'
ENABLE_CELERY_LONG: 'no'
ENABLE_CELERY_BEAT: 'no'
ADMIN_USER: 'admin'
ADMIN_EMAIL: 'admin@localhost'
ADMIN_PASSWORD: 'NeLr67Q#5z*oMD@foN79^dsQxyTEVezyG3c^v5W'
restart: on-failure
depends_on:
redis:
condition: service_healthy
web:
image: mediacms/mediacms:latest
deploy:
replicas: 1
ports:
- "11180:80"
volumes:
- /mnt/mediacms/deploy:/home/mediacms.io/mediacms/deploy
- /mnt/mediacms/media_files:/home/mediacms.io/mediacms/media_files
- /mnt/mediacms/logs:/home/mediacms.io/mediacms/logs
- /mnt/mediacms/settings.py:/home/mediacms.io/mediacms/cms/settings.py
environment:
# ENABLE_UWSGI: 'no'
ENABLE_CELERY_BEAT: 'no'
ENABLE_CELERY_SHORT: 'no'
ENABLE_CELERY_LONG: 'no'
ENABLE_MIGRATIONS: 'no'
celery_beat:
image: mediacms/mediacms:latest
volumes:
- /mnt/mediacms/deploy:/home/mediacms.io/mediacms/deploy
- /mnt/mediacms/media_files:/home/mediacms.io/mediacms/media_files
- /mnt/mediacms/logs:/home/mediacms.io/mediacms/logs
- /mnt/mediacms/settings.py:/home/mediacms.io/mediacms/cms/settings.py
environment:
ENABLE_UWSGI: 'no'
ENABLE_NGINX: 'no'
ENABLE_CELERY_SHORT: 'no'
ENABLE_CELERY_LONG: 'no'
ENABLE_MIGRATIONS: 'no'
celery_worker:
image: mediacms/mediacms:latest
deploy:
replicas: 1
volumes:
- /mnt/mediacms/deploy:/home/mediacms.io/mediacms/deploy
- /mnt/mediacms/media_files:/home/mediacms.io/mediacms/media_files
- /mnt/mediacms/logs:/home/mediacms.io/mediacms/logs
- /mnt/mediacms/settings.py:/home/mediacms.io/mediacms/cms/settings.py
environment:
ENABLE_UWSGI: 'no'
ENABLE_NGINX: 'no'
ENABLE_CELERY_BEAT: 'no'
ENABLE_MIGRATIONS: 'no'
depends_on:
- migrations
Hi, these are all valid suggestions, and I definitely want to get rid of the ENABLE_X variables any time soon...they have served well for a number of vanilla installations, but it's time to get the Docker setup updated.
Would you be interested to work on it and even open a PR?
adding this to my plate and check when I have time :)