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

0
0
Asked By CuriousDeveloper92 On

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.

2 Answers

Answered By DockerDude99 On

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!

CodeNinja84 -

Could you share your docker-compose.yml? I’d love to see how you set it up.

DevGal27 -

That sounds cool! What made you choose FrankenPHP?

Answered By TechWhiz On

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.

LearningCurve45 -

So, you really do code in the host environment? That’s neat!

HelpfulHacker -

Thanks for explaining that, it's super helpful!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.