Skip to content

masoudfesahat/laravel-with-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel with Docker and Make Command

Hey everyone!

I wanted to share a simple Docker setup to run Laravel without all the complexity. No need for Laravel Sail or anything like that. Plus, I wanted to make using Docker and artisan easier with the make command, so you don’t have to always be inside the Docker container to run things.

Getting Started

It’s super easy to set up. All you need to do is run these commands:

bash Copy Edit make up make install-laravel That's it. You’re good to go! I’ve set everything up for a smooth Laravel project experience, including:

  • nginx
  • Postgres
  • Redis
  • PgAdmin
  • npm

Key Features Here are a few cool things that make your life easier:

No need to go inside the container for Artisan commands Just use this syntax:

make artisan <command>

For example:

make artisan route:list

Composer made easy You can run Composer commands just like this:

make composer <command>

Automatic code formatting with Pint Clean up your code automatically with Pint.

To format your code:

make pint format

To check all files:

make pint format-all

Testing the project Run your tests easily with:

make test <command>

Other Available Commands: Here’s a list of all the available make commands and what they do:

make build              # Run docker compose build
make ps                 # View docker compose services
make up                 # Start the containers
make down               # Stop the containers
make down-volumes       # Stop containers and remove volumes
make restart            # Restart the containers
make composer           # Run any composer command
make tinker             # Open artisan tinker
make artisan            # Run any artisan command
make npm                # Run npm commands
make migration          # Create a new migration
make migrate            # Run artisan migrate
make horizon            # Start Laravel Horizon
make install-laravel    # Download Laravel source and update .env file
make pint               # Format your code with Pint
make test               # Run tests

Final Thoughts

With this setup, you can easily manage your Laravel project in Docker without the hassle. No more fiddling with Docker commands inside containers. You can handle everything from the outside using simple make commands.

Enjoy, and happy coding!

License

Overall, I got a lot of these ideas from this engineer and made some improvements myself. Their work was really amazing. Reza Khademi

About

run laravel with docker and make file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published