docker-mautic
docker-mautic copied to clipboard
Mautic need to become stateless in the Docker image
Important:
After running Mautic in docker I noticed a problem with state data retention. The current scenario is that on boot entry point checks the /var /www/html directory and will copy the source code from /usr/src/mautic if this directory is empty.
# docker-entrypoint.sh
if ! [ -e index.php -a -e app/AppKernel.php ]; then
echo >&2 "Mautic not found in $(pwd) - copying now..."
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
fi
tar cf - --one-file-system -C /usr/src/mautic . | tar xf -
echo >&2 "Complete! Mautic has been successfully copied to $(pwd)"
fi
Next will be the new installation and setting up of admin accounts, database information ... To save the installed information we need to mount the /var/www/html directory with the directory on the server.
So we cannot run multiple Mautic instances in a container-orchestration.
This is an old mindset and doesn't fit the trend of dockerize and run in modern container-orchestration like Kubernetes.
I suggest passing the installed information into the database so that when a new container starts up it runs with the existing database instead of going through the new installation.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I think this is caused by https://github.com/mautic/docker-mautic/issues/90 (and there's quite a bit of discussion about this on that issue)
I am going to work on this. I just does not know Mautic, could you please help me what to not forget about?
- database and many other settings can be configured by env already
- assets could be stored in S3
- move code to some other directory and configure Apache docroot there
Everything else could be empheral - could be deleted any time and is compatible with horizontal scaling (each container will have own empheral storage).
Is it all what I have to care about?
About database schema upgrades, I can not find info how it works in Mautic. Is there some script to run on each container start?
I am also going to use Mautic v4 only.
About database schema upgrades, I can not find info how it works in Mautic. Is there some script to run on each container start?
You could use an custom shell script which would run the necessary Symfony commands to apply database update after a container reboot.