m1n64/laravel-12-docker-startup

The skeleton application for the Laravel framework.

v1.0.4 2025-03-05 00:16 UTC

This package is auto-updated.

Last update: 2025-03-05 00:17:05 UTC


README

This is a Docker-based template for Laravel 12, built with:

  • PHP 8.4 (FPM on Alpine)
  • PostgreSQL 16
  • Redis (Alpine)
  • Node.js 22 + NPM
  • Supervisor for Queue & Scheduler
  • Makefile for easy commands (like Laravel Sail)
  • Nginx
  • Composer
  • XDebug in Dev Mode

And useful libraries:

🛠 Setup Instructions

1️⃣ Clone the Repository

composer create-project m1n64/laravel-12-docker-startup laravel-12-docker
cd laravel-12-docker

2️⃣ Copy .env and Update Configuration

cp .env.example .env
  • Open .env file and change it:
DB_DATABASE=<your-db> # Change DB name
  • Change the container name prefix:

    Inside docker-compose.yml, rename l12- to your project name:

services:
    app:
        container_name: myproject-app
    nginx:
        container_name: myproject-nginx
    postgres:
        container_name: myproject-postgres
    redis:
        container_name: myproject-redis
  • Change the Docker network

    In docker-compose.yml:

networks:
   myproject-network:

🚀 Start Containers

🔹 Using Docker

docker-compose up -d

🔹 Using Makefile

make up    # For development
make prod  # For production

📦 Install Dependencies

🛠 Install PHP Dependencies

Run inside the container:

docker-compose exec -u www-data app composer install

Or using Makefile:

make composer install

🎸 Install Node.js & NPM Dependencies

make npm install
make npm run dev   # Run Vite for development

🔑 Generate App Key

make artisan key:generate

📜 Run Migrations

make artisan migrate

🔗 Create Storage Symlink

make artisan storage:link

💻 Available Commands

🛠 Running Laravel Commands

Action Docker Command Makefile Shortcut
Run php artisan docker-compose exec -u www-data app php artisan <cmd> make artisan <cmd>
Run composer docker-compose exec -u www-data app composer <cmd> make composer <cmd>
Run npm docker-compose exec -u www-data app npm <cmd> make npm <cmd>
Open Bash docker-compose exec -u www-data app bash make bash
View Logs docker-compose logs -f app make logs app
Open PostgreSQL CLI docker-compose exec -e PGPASSWORD=<pass> postgres psql -U <user> -d <db> make psql
Open Redis CLI docker-compose exec redis redis-cli make redis

🛑 Managing Containers

🔄 Restart & Stop

Action Docker Command Makefile Shortcut
Restart all docker-compose restart make restart
Restart one docker-compose restart <service> make restart-container CONTAINER=<name>
Stop all docker-compose stop make stop
Stop one docker-compose stop <service> make stop-container CONTAINER=<name>
Start all docker-compose up -d make up
Remove all docker-compose down -v make down

For list of all makefile commands, run make help.

📜 Additional Notes

  • This setup supports Laravel Queues & Scheduler via Supervisor.
  • PostgreSQL, Redis & Supervisor are configured out of the box.
  • Uses Node.js 22 for Vite & frontend dependencies.
  • All Docker volumes persist data between container restarts.

🔥 Now your Laravel 12 project is fully containerized!

Use Makefile commands just like Laravel Sail, and enjoy seamless Docker development! 🚀

🤖 Authors