I have a simple Laravel application with Nginx, PHP and MySQL each in its own container. It works great in my development environment but for production I need to remove bind volumes and copy the contents to the image itself instead. But how do I do this?
I understand that the rule is that a production container should be immutable. Correct?
Do I need a seperate docker-compose-prod.yml file? How can I remove volues for production? How can I copy my source code and configuration to the image when deploying for production?
My “myphpapp” image store the application under /app and have an entrypoint script that check if the directory /var/www contain this version of the application and otherwise copy the whole /app to /var/www. This way both containers does see the application content (throw the app volume) while only one image have been created.
This way all you have to give for production is : the compose file and the nginx configuration everything else is within the myphpapp image.
@sebt3 If I have my app source code inside an image, won’t that mean that I have to re-build the image every time I make a change to my code? That makes development very difficult.
Well, all you have to do, is setup a CI/CD chain to build the images for you. Once done, a commit will generate your image.
Beside, on your developement host, nothing stop you from copying your current changes to :
docker volume inspect app -f '{{.Mountpoint}}'
which will have the same behaviour as your current setup
Le lun. 23 déc. 2019 à 10:59, Martin Zeltin via Docker Forums docker@discoursemail.com a écrit :