Skip to content

mayur-shingrakhiya/laravel-development-stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Laravel Dockerized

A complete Docker development environment for Laravel applications with PHP 8.3, MySQL 8.0, Nginx, and Node.js 20.

πŸš€ Features

  • PHP 8.3 FPM - Latest PHP version with all required extensions
  • MySQL 8.0 - Persistent database storage
  • Nginx - High-performance web server
  • Node.js 20 - For frontend asset compilation
  • Vite - Lightning-fast frontend tooling
  • Docker Volumes - Isolated vendor and node_modules management
  • Hot Module Replacement - Live reload for frontend changes

πŸ“‹ Prerequisites

πŸ› οΈ Installation

First Time Setup

  1. Clone the repository

    git clone https://github.com/YOUR_USERNAME/laravel-dockerized.git
    cd laravel-dockerized
  2. Run setup command

    npm run docker:setup

    This command will:

    • Start all Docker containers
    • Install Composer dependencies
    • Install NPM dependencies
    • Generate application key
    • Run database migrations
  3. Access the application

πŸ“¦ Available Commands

Daily Development

# Start containers
npm run docker:up

# Start Vite dev server (run in separate terminal)
npm run docker:dev

# Stop containers (database persists)
npm run docker:down

Management Commands

# Restart containers
npm run docker:restart

# Fresh start (clean database)
npm run docker:fresh

# Access container bash
npm run docker:bash

Laravel Artisan

# Run artisan commands
npm run artisan migrate
npm run artisan make:controller UserController
npm run artisan cache:clear
npm run artisan route:list

Composer

# Install package
npm run composer require package-name

# Update dependencies
npm run composer update

πŸ—‚οΈ Project Structure

laravel-dockerized/
β”œβ”€β”€ docker/
β”‚   └── nginx/
β”‚       └── default.conf       # Nginx configuration
β”œβ”€β”€ Dockerfile                 # PHP container configuration
β”œβ”€β”€ docker-compose.yml         # Docker services configuration
β”œβ”€β”€ package.json              # NPM scripts
└── README.md                 # This file

πŸ”§ Configuration

Environment Variables

The .env file contains your application configuration:

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel_dockerized
DB_USERNAME=laravel
DB_PASSWORD=

Vite Configuration

Ensure your vite.config.js has the correct server settings:

export default defineConfig({
    server: {
        host: '0.0.0.0',
        port: 5173,
        strictPort: true,
        hmr: {
            host: 'localhost',
            port: 5173,
        },
    },
});

πŸ“ Docker Services

Service Container Name Port Description
app laravel-dockerized-app 5173 PHP 8.3 FPM with Node.js
nginx laravel-dockerized-nginx 8000 Nginx web server
mysql laravel-dockerized-mysql 3306 MySQL 8.0 database

πŸ’Ύ Docker Volumes

  • vendor - Composer dependencies (isolated from local)
  • node_modules - NPM packages (isolated from local)
  • mysql_data - Database persistence

πŸ› Troubleshooting

Port Already in Use

# Check what's using the port
netstat -ano | findstr :8000

# Stop containers and try again
npm run docker:down
npm run docker:up

Permission Issues

# Rebuild containers
docker-compose down -v
docker-compose build --no-cache
docker-compose up -d

Clear All Docker Data

# Remove everything including volumes
docker-compose down -v

# Remove all unused Docker resources
docker system prune -a

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is open-sourced software licensed under the MIT license.

πŸ‘¨β€πŸ’» Author

Your Name - Mayur Shingrakhiya

πŸ™ Acknowledgments

About

🐳 Complete Docker development environment for Laravel with PHP 8.3, MySQL, Nginx & Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages