I am developing a Symfony application where users can upload there own pictures, documents and more. I want to deploy this application with docker using 3 containers (nginx, php-fpm and mysql) on a VPS (Digital Ocean droplet). The way I would like to do this is creating the image locally, pushing it to the register, pulling form the server and run the install script.
Problems with redeploying and making backups:
1.How to back up the full project directory that resides in the php-fpm container (the source code and the user uploaded files) to another directory on the VPS?
2.How to share newly uploaded documents from the php-fpm container with the Nginx container?
3.How to can I make sure the user uploaded files are available to the application after redeploying?
Solutions I am considering
I am trying to come up with a good solution for the above problems for the past week and this is what I have thought of so far:
Current solution to problem 1:
Pulling all the code via git on the host and then using a bind-mount to make the data available in the docker container. However, this goes against the whole principle of being able to spin up the docker image anywhere independent of the host.
Current solution to problem 2 and 3: Using volumes
This solution however requires me to setup new volumes if someone on the team creates a new upload directory. If the team member does not communicate the new directory (or doesn’t know that he has to communicate it) people will upload files and the files will then not be there anymore when a new version is deployed.
I really have the feeling that there are better solutions possible and would like to ask you guys if you know solutions to the problems above.