https://github.com/mrtolouei/laravel-dockerized
A complete Laravel project with Docker configuration for easy development and quick deployment
https://github.com/mrtolouei/laravel-dockerized
docker docker-compose laravel laravel-docker laravel-dockerize
Last synced: about 2 months ago
JSON representation
A complete Laravel project with Docker configuration for easy development and quick deployment
- Host: GitHub
- URL: https://github.com/mrtolouei/laravel-dockerized
- Owner: mrtolouei
- Created: 2025-07-27T10:12:17.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-07-27T16:03:29.000Z (11 months ago)
- Last Synced: 2025-08-09T08:19:34.813Z (11 months ago)
- Topics: docker, docker-compose, laravel, laravel-docker, laravel-dockerize
- Language: Blade
- Homepage:
- Size: 72.3 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🚀 Laravel Dockerized Project
A complete Laravel project with Docker configuration for easy development and quick deployment
[](https://laravel.com)
[](https://www.docker.com)
[](https://php.net)
[](https://www.postgresql.org)
[](https://www.mysql.com)
[](https://redis.io)
## ✨ Project Features
- ✅ Complete Docker and docker-compose configuration
- ✅ PHP 8.3 with all required Laravel extensions
- ✅ Optimized Nginx server for Laravel
- ✅ Database options: PostgreSQL 16 or MySQL 8.0
- ✅ Redis for cache and queues
- ✅ Auto-configured Xdebug for debugging
- ✅ Cron job management with Supercronic
- ✅ Consistent and reproducible development environment
## 🛠 Prerequisites
- [PHP](https://www.php.net/)
- [Composer](https://getcomposer.org/download/)
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)
- [Git](https://git-scm.com/downloads)
## 🚀 Project Setup
1. Clone the project:
```bash
git clone git@github.com:mrtolouei/laravel-dockerized.git
cd laravel-dockerized
```
2. Copy env file:
```bash
cp .env.example .env
```
3. Build and run containers:
```bash
docker compose up -d --build
```
4. Install dependencies:
```bash
docker exec -it laravel_php composer install --ignore-platform-reqs
```
5. Generate application key:
```bash
docker exec -it laravel_php php artisan key:generate
```
6. Run migrations:
```bash
docker exec -it laravel_php php artisan migrate
```
7. Project is ready!:
- Open in browser: [http://localhost:8000](http://localhost:8000)
## 🏗 Docker Structure
- **nginx:** Web server with optimized configuration for Laravel
- **php:** PHP 8.3 service with all required extensions
- **postgres:** PostgreSQL 16 database (default)
- **mysql:** MySQL 8.0 database (commented by default)
- **redis:** Redis service for cache and queues
## ⚙ Environment Configuration
### Database Selection
You can choose between PostgreSQL or MySQL by:
1. Uncommenting your preferred database service in `docker-compose.yml`
2. Commenting out the other database service
3. Updating the `.env` file with appropriate DB configuration
Default values in `.env` (PostgreSQL):
```text
# For PostgreSQL use:
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=secret
# For MySQL use:
# DB_CONNECTION=mysql
# DB_HOST=mysql
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=laravel
# DB_PASSWORD=secret
```
## 🔄 Switching Between Databases
1. To switch to MySQL:
- Uncomment the MySQL service in `docker-compose.yml`
- Comment the PostgreSQL service
- Update `.env` with MySQL credentials
- Rebuild containers: `docker-compose up -d --build`
2. To switch back to PostgreSQL:
- Uncomment the PostgreSQL service
- Comment the MySQL service
- Update `.env` with PostgreSQL credentials
- Rebuild containers: `docker-compose up -d --build`
Note: Make sure to backup your data before switching databases as each uses different volumes.