A comprehensive Docker-based development environment for modern PHP applications with Laravel, featuring a complete stack with MySQL, Redis, RabbitMQ, and Nginx. This project aims to provide a consistent, reproducible development environment that closely mirrors production.
- Provide a consistent development environment across team members
- Simplify onboarding for new developers
- Ensure development-production parity
- Enable easy testing and debugging
- Support modern PHP development practices
- Docker and Docker Compose installed
- Git (optional, for cloning the repository)
-
Clone the repository:
git clone https://github.com/PortilloDev/opentrackerapi.git cd opentrackerapi -
Configure environment variables:
cp .env.example .env
Edit the
.envfile to adjust database credentials and other settings. -
Build and start the containers:
docker-compose up -d
-
Install PHP dependencies:
docker-compose exec app composer install -
Set up the application:
docker-compose exec app php artisan key:generate docker-compose exec app php artisan migrate
-
For frontend assets (if using Tailwind CSS):
docker-compose exec node npm install docker-compose exec node npm run dev
-
Access your application at http://localhost:8022
This development environment includes:
-
Laravel 11.9: Modern PHP Framework
-
PHP 8.2: With essential extensions:
- intl, zip, apcu, opcache
- pcov (for code coverage)
- pdo, pdo_mysql (for database connectivity)
- amqp (for messaging)
- redis (for caching)
- xdebug (for debugging)
- gd (for image processing)
-
MySQL 8.0: Relational database management system
-
Redis 7.0.10: In-memory data structure store for caching
-
RabbitMQ 3: Message broker for asynchronous communication
-
Nginx: High-performance web server
- Node.js: For asset compilation with Tailwind CSS
- Composer: PHP dependency manager
- Xdebug: For debugging and code coverage analysis
project/
βββ docker/ # Docker configurations
β βββ nginx/ # Nginx configuration
β β βββ default.conf # Web server configuration
β β βββ Dockerfile # Nginx image
β βββ php/ # PHP configuration
β β βββ Dockerfile # PHP image with extensions
β βββ node/ # Node.js configuration
β βββ Dockerfile # Image for Tailwind CSS
βββ docker-compose.yml # Service definitions
βββ .env # Environment variables
βββ README.md # This file
# View logs from all containers
docker-compose logs -f
# View logs from a specific service
docker-compose logs -f app
# Restart all services
docker-compose restart
# Restart a specific service
docker-compose restart app
# Stop all containers
docker-compose down
# Stop and remove volumes (caution! data will be lost)
docker-compose down -v# Run PHP commands
docker-compose exec app php -v
# Access MySQL
docker-compose exec mysql mysql -u app -p
# Run Composer commands
docker-compose exec app composer update
# Run npm commands
docker-compose exec node npm install <package>
# Run Laravel Artisan commands
docker-compose exec app php artisan migrateThe environment is configured with volumes that allow real-time development. Changes to source code are immediately reflected without the need to rebuild containers.
To run tests inside the PHP container:
# PHPUnit
docker-compose exec app vendor/bin/phpunit
# With code coverage (PCOV is installed)
docker-compose exec app vendor/bin/phpunit --coverage-html ./coverage- Xdebug is configured for development, debugging, and code coverage
- MySQL data is persisted in a Docker volume
- Nginx configuration is optimized for modern PHP applications
- Redis data is persisted with AOF (Append Only File)
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure your code follows the project's coding standards and includes appropriate tests.
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name - ivan.portillo@notasweb.me
Project Link: https://github.com/PortilloDev/opentrackerapi.git
βοΈ Developed with β€οΈ by IvΓ‘n Portillo