DEV Community

Discussion on: Deploying Your Laravel App on Docker, With NGINX and MySQL

Collapse
 
palaciosdiego profile image
Diego Palacios

Hi Brian, it take me so long but finally i could make my app work, i only have a doubt, how i can reload changes in my code to the app container without rebuilding the whole thing. Thanks!

Collapse
 
baliachbryan profile image
Brian Baliach

Hello there Diego! Well, if you're on your development environment, you could set up a new volume in your docker-compose file that you can link to your project's root directory. That way, any changes you make to code will be reflected automatically in your docker container

Collapse
 
deulizealand profile image
DeUliZeaLand

Hi brian , can you give me some example to do that ?

Thread Thread
 
baliachbryan profile image
Brian Baliach

Hello there DeUliZeaLand, Highlighting from part of my post: When we were defining the Laravel App container inside our docker-compose file, we defined a volumes entry: ./storage:/var/www/storage whereby the left side before the colon represents our host machine and the right side after the colon represents our docker machine. So in this case, instead of just using the storage folder, you can adjust this entry to become: .:/var/www which will now link you entire project to your docker container. Again, only do this in your development environment, not your production environment.

Thread Thread
 
elerocks profile image
elerocks

Hello Brian,
can you elaborate why it isn't good idea to do it in production environment?

Thread Thread
 
baliachbryan profile image
Brian Baliach

Hello there, for starters, we have different configurations for our production and development environment. As such, we only want to persist the necessary files for production in our production environment. Because of this, we'd rather not create a volume that persists our entire project folder, but rather we want the volume to persist only our necessary files. That's why we have used commands like COPY so that we only copy necessary files that we have no problem discarding when re-creating our docker container and we've only persisted necessary data like the Storage folder which store user data.

Thread Thread
 
deulizealand profile image
DeUliZeaLand

Thanks for your explanation Brian. It's very great tutorial. Hope you make some other tutorial again docker