Architecture Overview
Macuin Laravel uses a containerized architecture with Docker Compose orchestrating multiple services:| Service | Image | Description | Port |
|---|---|---|---|
| Nginx | nginx:1.27-alpine | Web server handling HTTP requests | 8000 |
| Laravel App | php:8.3-fpm (custom) | PHP-FPM running Laravel 12 | internal |
| PostgreSQL | postgres:16-alpine | Database server | 5432 |
| Node | node:22-alpine | Frontend asset compilation with Vite | 5173 |
Prerequisites
Required Software
Before installing Macuin Laravel, ensure you have the following installed on your system:Docker
Container runtime engineDownload Docker
Docker Desktop
Docker management interface (recommended)Download Docker Desktop
Docker Compose
Multi-container orchestration toolIncluded with Docker Desktop
Git
Version control systemDownload Git
System Requirements
- OS: Linux, macOS, or Windows with WSL2
- RAM: Minimum 4GB, recommended 8GB+
- Disk Space: At least 5GB free space
- Ports: 8000, 5432, and 5173 must be available
Installation Steps
Clone the Repository
Clone the Macuin Laravel repository from GitHub:Verify the project structure:You should see files including:
docker-compose.ymlcomposer.json.env.exampledocker/directory
Build and Start Containers
Build the Docker images and start all services:This command will:Verify all containers are running:You should see 4 containers:
- Build the custom PHP 8.3-FPM container with PostgreSQL extensions
- Pull official images for Nginx, PostgreSQL, and Node.js
- Create a bridge network for service communication
- Start all containers in detached mode
The initial build process may take 5-10 minutes depending on your internet connection.
laravel_nginxlaravel_applaravel_postgreslaravel_node
Install PHP Dependencies
Access the Laravel application container:Install Composer dependencies:This installs Laravel 12 and all required packages including:
- Laravel Framework
- Laravel Tinker
- PHPUnit for testing
- Laravel Pint for code formatting
Configure Environment Variables
Create your environment configuration file:The
.env file is automatically configured for Docker by the docker-compose.yml environment variables, but you should verify the settings:.env
Generate Application Key
Generate a unique application encryption key:This updates the
APP_KEY in your .env file. This key is used for:- Session encryption
- Password hashing
- Secure cookie encryption
Run Database Migrations
Execute database migrations to create the schema:This creates all necessary tables in the PostgreSQL database.
The PostgreSQL service includes a health check that ensures the database is ready before the app container starts.
Environment Variables
Application Configuration
.env
Database Configuration
.env
Session & Cache Configuration
.env
Logging
.env
Mail Configuration
.env
Frontend Assets
.env
Docker Configuration
Container Details
Thedocker-compose.yml defines the following services:
PostgreSQL Service
PostgreSQL Service
docker-compose.yml
Laravel App Service
Laravel App Service
docker-compose.yml
- PHP 8.3-FPM
- PostgreSQL PDO extensions
- Composer 2
- Git, curl, unzip, zip
Nginx Service
Nginx Service
docker-compose.yml
Node Service
Node Service
docker-compose.yml
Development Workflow
Composer Scripts
The project includes helpful Composer scripts:Useful Docker Commands
Laravel Artisan Commands
Common Artisan commands for development:Troubleshooting
Port Already in Use
Port Already in Use
Problem: Error message “port is already allocated” when running
docker compose up.Solution:-
Check which process is using the port:
-
Stop the conflicting process or modify
docker-compose.ymlto use different ports:
Database Connection Failed
Database Connection Failed
Problem: Laravel cannot connect to PostgreSQL database.Solution:
-
Verify containers are running:
-
Check PostgreSQL health:
-
Verify environment variables match in
.envanddocker-compose.yml:DB_HOST=postgres(container name)DB_DATABASE=laravelDB_USERNAME=laravelDB_PASSWORD=secret
-
Restart services:
Permission Denied Errors
Permission Denied Errors
Problem: Permission errors when accessing files inside containers.Solution:
-
The PHP container runs as user
appuser(UID 1000, GID 1000) -
Fix file permissions on host:
-
Inside container:
Composer Install Fails
Composer Install Fails
Problem:
composer install fails with memory errors or network issues.Solution:-
Increase PHP memory limit:
-
Clear Composer cache:
-
Try with verbose output:
npm/Node Issues
npm/Node Issues
Problem: Frontend assets not compiling or Vite not starting.Solution:
-
Check Node container logs:
-
Rebuild node_modules:
-
Restart Node container:
Container Won't Start
Container Won't Start
Problem: Container exits immediately or won’t start.Solution:
-
Check container logs:
- Verify Docker resources (CPU, memory, disk space)
-
Rebuild containers from scratch:
Migrations Fail
Migrations Fail
Problem: Database migrations fail or tables not created.Solution:
-
Ensure PostgreSQL is healthy:
-
Check database connection:
-
Run migrations with verbose output:
-
Fresh migration if needed:
Next Steps
Now that you have Macuin Laravel installed, you can:Configure Features
Set up mail, cache, and queue configurations
Develop Features
Start building your automotive parts e-commerce features
Run Tests
Execute PHPUnit tests with
composer testDeploy to Production
Prepare for production deployment