This guide walks you through creating a Laravel backend and a Next.js frontend, all within a Dockerized environment. You can have everything up and running in just a few minutes.
- Docker and Docker Compose installed on your system
- Basic knowledge of Laravel and Next.js
- Basic knowledge of command-line usage
git clone https://github.com/softjapan/laravel-nextjs-dev-environment.git
By default, this setup uses MySQL. We will skip running migrations at this point and do them later. Other options use default settings.
cd laravel-nextjs-dev-environment
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev laravel new laravel-backend
We will install Laravel Breeze (API scaffolding) without running migrations at this stage. Migrations will be run later after configuring the .env
file and starting the Docker containers.
cd laravel-backend
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev composer require laravel/breeze --dev
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev php artisan breeze:install api
cd ..
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev git clone https://github.com/laravel/breeze-next.git next-frontend
cd next-frontend
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev npm install
These files contain database connection details and other environment variables.
cd ..
cp ./envfiles/laravel-backend/.env ./laravel-backend/.env
cp ./envfiles/next-frontend/.env ./next-frontend/.env
docker compose up -d
Once the containers are running and your .env
files are in place, apply the migrations:
docker exec -it laravel-backend php artisan migrate
Open your browser and navigate to:
http://localhost:3000
When you’re done, shut down the containers:
docker compose down
This project is open source and available under the MIT License.
Contributions are welcome! Feel free to open a pull request with improvements or suggestions.
For questions or additional support, please open an issue in this repository.
Enjoy your streamlined Laravel + Next.js development setup!