- Notifications
You must be signed in to change notification settings - Fork1
PHP Container for maintaining Laravel applications
License
Atyantik/docker-laravel-php
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This repository provides acustom PHP 8.4 Docker image based on the Bullseye distribution, optimized for running Laravel applications. It includes pre-installed PHP extensions, tools, and multi-architecture support forAMD64 andARM64. 🚀
This Dockerfile is tailored forLaravel applications and includes the following features:
- PHP 8.4 with FPM (FastCGI Process Manager).
- ✅Pre-installed PHP Extensions:
- Essential extensions required by most Laravel applications.
- See theExtension Table below for a full list. 🧩
- ✅Pre-installed Tools:
- Composer (globally available for dependency management).
- MongoDB Tools (e.g.,
mongodump) for database backups and operations.
- ✅Xdebug:
- Included but disabled by default for production readiness.
- XDebug 3.4.0beta1 is used for compatibility with php 8.4
- ✅Multi-Architecture Builds:
- Supports both AMD64 (x86_64) and ARM64 (aarch64) architectures.
Here's a detailed list of pre-installed PHP extensions:
| Extension | Description | Status |
|---|---|---|
| pdo_mysql | MySQL database support | ✅ |
| pdo_pgsql | PostgreSQL database support | ✅ |
| pdo_sqlite | SQLite lightweight database support | ✅ |
| mbstring | Multibyte string handling for UTF-8 support | ✅ |
| intl | Internationalization and localization features | ✅ |
| gd | Image processing (JPEG, PNG) | ✅ |
| zip | Support for ZIP compression | ✅ |
| opcache | Performance optimization through script caching | ✅ |
| soap | SOAP-based web services | ✅ |
| redis | Redis for caching and sessions | ✅ |
| memcached | Memcached for caching and sessions | ✅ |
| mongodb | MongoDB database support | ✅ |
| gmp | Arbitrary precision arithmetic | ✅ |
| exif | Metadata handling for images | ✅ |
| imagick | ImageMagick image processing and manipulation | ✅ |
Composer:
- Installed globally for dependency management.
- Optimized to use only HTTPS for Packagist repositories.
MongoDB Tools:
- Includesmongodump for backup operations and other utilities.
This Docker image is available onDocker Hub. You can pull it directly or use it as a base image in your own Dockerfile:
FROM atyantik/laravel-php:8.4-bullseye- Build your Laravel application image using this base image:
FROM atyantik/laravel-php:8.4-bullseyeCOPY . /var/www/htmlWORKDIR /var/www/htmlRUN composer install --no-dev --optimize-autoloader
- Start the container:
docker run -p 8000:9000 my-laravel-app
Follow these steps to build the image yourself:
Clone the Repository:
git clone https://github.com/atyantik/laravel-php-docker.gitcd laravel-php-dockerEnable Buildx for Multi-Architecture Builds:
- If Buildx is not set up, enable it by followingDocker's Buildx Guide.
Build AMD64 Image:
docker buildx build --platform="linux/amd64" -t atyantik/laravel-php:8.4-bullseye-amd64.
Build ARM64 Image:
docker buildx build --platform="linux/arm64" -t atyantik/laravel-php:8.4-bullseye-arm64.
Push Images to Docker Hub:
docker push atyantik/laravel-php:8.4-bullseye-amd64docker push atyantik/laravel-php:8.4-bullseye-arm64
Create and Push a Manifest for Multi-Architecture:
docker manifest create atyantik/laravel-php:8.4-bullseye \ atyantik/laravel-php:8.4-bullseye-amd64 \ atyantik/laravel-php:8.4-bullseye-arm64docker manifest push atyantik/laravel-php:8.4-bullseye
💻 Visit us at:atyantik.com
This repository includes two types of example configurations to help you get started:
Located inexample/general/, this is a simple setup for any PHP application:
services:app:image:atyantik/laravel-php:8.4-bullseyevolumes: -./public:/var/www/html -./php/php.ini:/usr/local/etc/php/php.iniwebserver:image:nginx:latestvolumes: -./public:/var/www/html -./nginx/default.conf:/etc/nginx/conf.d/default.confports: -"8080:80"depends_on: -app
This configuration provides:
- PHP-FPM service using our custom image
- Nginx web server
- Basic volume mounting for code and configuration
- Simple networking between services
Located inexample/laravel/, this is a comprehensive setup for Laravel applications with two environments:
A complete development environment with:
- PostgreSQL database
- Redis for caching and queues
- Mailpit for email testing
- pgAdmin for database management
- Memcached for caching
- MinIO for S3-compatible storage
- Supervisor for queue workers
- Nginx web server
- Vite support for frontend development
Key features:
- Hot-reloading for development
- Persistent data storage
- Development tools (Mailpit, pgAdmin)
- Local storage for files and databases
A production-like environment with:
- Optimized PHP configuration
- Secure Redis setup
- Persistent volumes
- SSL support
- Production-ready Nginx configuration
- Bootstrapper for initial setup
Key differences from development:
- No development tools
- Secure configurations
- Production-ready settings
- Volume-based storage
- SSL support
For General PHP Applications:
cd example/generaldocker-compose up -dAccess your application at
http://localhost:8080For Laravel Applications:To integrate these Docker configurations into your existing Laravel project:
Copy the following files from
example/laravel/to your project root:compose.yml(for development)compose.staging.yml(for staging)docker/directory with all its contents
Update your Laravel configuration files:
- In
bootstrap/app.php, ensure allowing trustedProxies - In
vite.config.js, update the server.hmr - In your project's
.envfile, add these variables:
- In
DB_CONNECTION=mysqlDB_HOST=dbDB_PORT=3306DB_DATABASE=laravelDB_USERNAME=local_laravelDB_PASSWORD=local@laravelREDIS_CLIENT=phpredisREDIS_HOST=redisREDIS_PASSWORD=nullREDIS_PORT=6379MAIL_MAILER=logMAIL_SCHEME=nullMAIL_HOST=mailMAIL_PORT=1025MAIL_USERNAME=nullMAIL_PASSWORD=nullMAIL_FROM_ADDRESS="hello@example.com"MAIL_FROM_NAME="${APP_NAME}"AWS_ACCESS_KEY_ID=minioadminAWS_SECRET_ACCESS_KEY=minioadminAWS_DEFAULT_REGION=us-east-1AWS_BUCKET=laravel-bucketAWS_USE_PATH_STYLE_ENDPOINT=trueAWS_ENDPOINT=http://s3:9000MEMCACHED_HOST=memcachedCACHE_STORE=memcachedQUEUE_CONNECTION=redisFILESYSTEM_DISK=s3APP_URL=https://laravel.localhostCOMPOSE_BAKE=true
- Start the services:
# Developmentdocker compose up -d# Stagingdocker compose -f compose.staging.yml up -d
Development:
- Use the development configuration for local development
- Enable Xdebug when needed
- Use Mailpit for email testing
- Utilize pgAdmin for database management
Staging:
- Use the staging configuration as a base
- Implement proper SSL certificates
- Set secure passwords for all services
- Use persistent volumes for data
- Configure proper backup strategies
- Whenever possible use proper staging configuration not the provided docker-compose.yml
- The provided configurations is to get staging server quick up and running on single server instance.
Security:
- Never commit sensitive environment variables
- Use strong passwords in production
- Implement proper SSL/TLS
- Regularly update container images
- Docker Hub Repository:https://hub.docker.com/repository/docker/atyantik/laravel-php
- Atyantik Technologies:atyantik.com
AtAtyantik Technologies, we specialize in building world-class software solutions with a focus on innovation, scalability, and efficiency. We believe in delivering value through cutting-edge technologies and industry best practices.
About
PHP Container for maintaining Laravel applications
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Contributors3
Uh oh!
There was an error while loading.Please reload this page.
