Date:

Set Up a Laravel Backend and Next.js Frontend Development Environment with Docker within 5 minutes

Here is the rewritten article:

Prerequisites

  • Docker and Docker Compose installed on your system
  • Basic knowledge of Laravel and Next.js

Basic Knowledge of Command-Line Usage

1. Clone the Repository

git clone https://github.com/softjapan/laravel-nextjs-dev-environment.git

2. Create the Laravel Backend

docker run --rm -it -v $PWD:/app softjpn/laravel-nodejs-dev laravel new laravel-backend

3. Install Laravel Breeze and Dependencies

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

4. Create the Next.js Frontend

cd ..
docker run --rm -it -v $PWD:/app softjpn/laravel-nodejs-dev git clone https://github.com/laravel/breeze-next.git next-frontend

5. Install Frontend Dependencies

cd next-frontend
docker run --rm -it -v $PWD:/app softjpn/laravel-nodejs-dev npm install

6. Create the Environment Files

cd ..
cp ./envfiles/laravel-backend/.env ./laravel-backend/.env
cp ./envfiles/next-frontend/.env ./next-frontend/.env

7. Start the Docker Containers

docker-compose up -d

8. Run Database Migrations

docker exec -it laravel-backend php artisan migrate

9. Access the Frontend

http://localhost:3000

10. Stop the Docker Containers

docker-compose down

Screenshot

License

This project is open source and available under the MIT License.

Contributing

Contributions are welcome! Feel free to open a pull request with improvements or suggestions.

Contact

For questions or additional support, please open an issue in this repository.

Enjoy your streamlined Laravel + Next.js development setup!

Latest stories

Read More

LEAVE A REPLY

Please enter your comment!
Please enter your name here