This repository provides a custom 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 for AMD64 and ARM64. π
This Dockerfile is tailored for Laravel 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 the Extension 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 | β |
-
Composer:
- Installed globally for dependency management.
- Optimized to use only HTTPS for Packagist repositories.
-
MongoDB Tools:
- Includes mongodump for backup operations and other utilities.
This Docker image is available on Docker 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-bullseye COPY . /var/www/html WORKDIR /var/www/html RUN 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.git cd laravel-php-docker
-
Enable Buildx for Multi-Architecture Builds:
- If Buildx is not set up, enable it by following Docker'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-amd64 docker 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-arm64 docker 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 in example/general/
, this is a simple setup for any PHP application:
services:
app:
image: atyantik/laravel-php:8.4-bullseye
volumes:
- ./public:/var/www/html
- ./php/php.ini:/usr/local/etc/php/php.ini
webserver:
image: nginx:latest
volumes:
- ./public:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "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 in example/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/general docker-compose up -d
Access your application at
http://localhost:8080
-
For 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
.env
file, add these variables:
- In
-
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=local_laravel
DB_PASSWORD=local@laravel
REDIS_CLIENT=phpredis
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=mail
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=laravel-bucket
AWS_USE_PATH_STYLE_ENDPOINT=true
AWS_ENDPOINT=http://s3:9000
MEMCACHED_HOST=memcached
CACHE_STORE=memcached
QUEUE_CONNECTION=redis
FILESYSTEM_DISK=s3
APP_URL=https://laravel.localhost
COMPOSE_BAKE=true
- Start the services:
# Development docker compose up -d # Staging docker 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
At Atyantik 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.