How do I set up a Laravel, PostgreSQL, and React project with Docker?

April 21, 2025 2 answers
Asked by +CopyTheForm
I'm new to working with Docker and I'm trying to start a project that uses Laravel, PostgreSQL, and React. Is it enough to just create empty containers and then initialize my project in there? I'm also concerned about whether the changes I make will reflect on my host machine and vice versa. If possible, could you provide some example Dockerfiles and a docker-compose file for this stack? I've heard there are ways to make changes sync between the host and the containers, but I'm not sure how to set that up.

Answers

cranberry bog
Understanding how volumes work is crucial here. In my setup, I mount the Laravel source from the host machine. This way, any changes you make in your IDE reflect immediately in the container! Just ensure you have Composer and NodeJS installed in your workspace container to run PHP and npm commands effectively.

mtu.1280: Thanks for explaining that, it's super helpful!

Ahem: So, you really do code in the host environment? Thatโ€™s neat!

Reply to this answer
+63 feet below
I totally recommend using Docker for Laravel! Here's a quick look at my setup: - I use a custom FrankenPHP image as my web server. - For my workspaces, I have a separate custom PHP8 image (though sometimes I use the same FrankenPHP image for simplicity). - My database is backed by PostgreSQL 17, and I also run Portainer for management and pgAdmin for database administration. - I even use Directus to help with database building. This setup works great for development!

37 paper folds: Could you share your docker-compose.yml? Iโ€™d love to see how you set it up.

stackPtr.0C: That sounds cool! What made you choose FrankenPHP?

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions