Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PHP Container for maintaining Laravel applications

License

NotificationsYou must be signed in to change notification settings

Atyantik/docker-laravel-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Docker Hub

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. 🚀


✨ Features: What This Dockerfile Provides

This Dockerfile is tailored forLaravel applications and includes the following features:

  1. PHP 8.4 with FPM (FastCGI Process Manager).
  2. Pre-installed PHP Extensions:
    • Essential extensions required by most Laravel applications.
    • See theExtension Table below for a full list. 🧩
  3. Pre-installed Tools:
    • Composer (globally available for dependency management).
    • MongoDB Tools (e.g.,mongodump) for database backups and operations.
  4. Xdebug:
    • Included but disabled by default for production readiness.
    • XDebug 3.4.0beta1 is used for compatibility with php 8.4
  5. Multi-Architecture Builds:
    • Supports both AMD64 (x86_64) and ARM64 (aarch64) architectures.

🧩 PHP Extensions

Here's a detailed list of pre-installed PHP extensions:

ExtensionDescriptionStatus
pdo_mysqlMySQL database support
pdo_pgsqlPostgreSQL database support
pdo_sqliteSQLite lightweight database support
mbstringMultibyte string handling for UTF-8 support
intlInternationalization and localization features
gdImage processing (JPEG, PNG)
zipSupport for ZIP compression
opcachePerformance optimization through script caching
soapSOAP-based web services
redisRedis for caching and sessions
memcachedMemcached for caching and sessions
mongodbMongoDB database support
gmpArbitrary precision arithmetic
exifMetadata handling for images
imagickImageMagick image processing and manipulation

🛠 Pre-installed Tools

  1. Composer:

    • Installed globally for dependency management.
    • Optimized to use only HTTPS for Packagist repositories.
  2. MongoDB Tools:

    • Includesmongodump for backup operations and other utilities.

🚀 How to Use

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

Example: Running a Laravel Application

  1. 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
  2. Start the container:
    docker run -p 8000:9000 my-laravel-app

🛠 Compilation Steps

Follow these steps to build the image yourself:

  1. Clone the Repository:

    git clone https://github.com/atyantik/laravel-php-docker.gitcd laravel-php-docker
  2. Enable Buildx for Multi-Architecture Builds:

  3. Build AMD64 Image:

    docker buildx build --platform="linux/amd64" -t atyantik/laravel-php:8.4-bullseye-amd64.
  4. Build ARM64 Image:

    docker buildx build --platform="linux/arm64" -t atyantik/laravel-php:8.4-bullseye-arm64.
  5. Push Images to Docker Hub:

    docker push atyantik/laravel-php:8.4-bullseye-amd64docker push atyantik/laravel-php:8.4-bullseye-arm64
  6. 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

📚 Examples and Docker Configurations

This repository includes two types of example configurations to help you get started:

1. General PHP Application Setup

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

2. Laravel-Specific Setup

Located inexample/laravel/, this is a comprehensive setup for Laravel applications with two environments:

Local Development (compose.yml)

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

Staging Environment (compose.staging.yml)

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

How to Use These Examples

  1. For General PHP Applications:

    cd example/generaldocker-compose up -d

    Access your application athttp://localhost:8080

  2. For Laravel Applications:To integrate these Docker configurations into your existing Laravel project:

    1. Copy the following files fromexample/laravel/ to your project root:

      • compose.yml (for development)
      • compose.staging.yml (for staging)
      • docker/ directory with all its contents
    2. Update your Laravel configuration files:

      • Inbootstrap/app.php, ensure allowing trustedProxies
      • Invite.config.js, update the server.hmr
      • In your project's.env file, add these variables:
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
  1. Start the services:
    # Developmentdocker compose up -d# Stagingdocker compose -f compose.staging.yml up -d

Best Practices

  1. Development:

    • Use the development configuration for local development
    • Enable Xdebug when needed
    • Use Mailpit for email testing
    • Utilize pgAdmin for database management
  2. 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.
  3. Security:

    • Never commit sensitive environment variables
    • Use strong passwords in production
    • Implement proper SSL/TLS
    • Regularly update container images

🌐 Links


🤝 About Atyantik Technologies

Atyantik Logo

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp