Skip to content

Latest commit

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Braz Docker PHP Project

This project provides a collection of optimized Docker images to run PHP applications in various scenarios.

With a focus on flexibility and performance, the images are organized into categories that cater to everything from command-line tools to full development and production stacks.

Each image is carefully maintained and regularly updated to ensure compatibility and security.

For more technical information, please visit our DeepWiki Page (AI generated).

Table of Contents

  1. Who is this for?
  2. About the author
  3. Available Images
  4. Features
  5. Build Status
  6. Donation

Who is this for?

This project is designed for developers, system administrators, and DevOps engineers who need a reliable and efficient way to run PHP applications in Docker containers.

Whether you're building a new application, maintaining an existing one, or looking to streamline your development workflow, these images provide the tools and flexibility you need.

About the author

My name is Felipe Braz, I am a DevOps engineer and System Administrator with a passion for open-source software and Docker.

Although my career has taken me in directions away from PHP, I still hold a deep passion for the language that introduced me to the world of technology and software development.

I believe in the power of collaboration and open-source software, and I hope this project can help you in your development journey.

Available Images

Tools Images

A variety of tools images to help you manage your PHP applications:

Usage

# Run a standalone PHP script
docker run -it --rm fbraz3/php-cli:latest php myscript.php
# Run a PHP built-in server with Phalcon framework support
docker run -it --rm -v $(pwd):/workspace -p 8000:8000 fbraz3/php-cli:latest-phalcon php -S localhost:8000
# Install a fresh wordpress using wp-cli
docker run -it --rm -v $(pwd):/workspace fbraz3/wp-cli:latest core download --path=/workspace
# Install a fresh symfony using symfony-cli
docker run -it --rm -v $(pwd):/workspace fbraz3/symfony-cli:latest new my_project_name

You may want to add these executable aliases to your .bashrc or .zshrc for convenience.

PHP_VERSION=8.4 # Replace with your preferred PHP versionphp() { docker run -v "$(pwd):/workspace" --rm fbraz3/php-cli:$PHP_VERSION"$@"; }
composer() { docker run -v "$(pwd):/workspace" --rm fbraz3/php-composer:$PHP_VERSION"$@"; }
wp() { docker run -v "$(pwd):/workspace" --rm fbraz3/wp-cli:$PHP_VERSION"$@"; }
symfony() { docker run -v "$(pwd):/workspace" --rm fbraz3/symfony-cli:$PHP_VERSION"$@"; }

Source Code

fbraz3/php-base-docker

Backend Images

Images focusing on PHP server backend for easy integration with most commons web servers:

  • PHP-FPM: PHP FastCGI Process Manager, designed to work with a separate web server, such as Nginx or Apache2.

Usage

Step 1: Run PHP-FPM image and expose port 1780/TCP

# Run a PHP-FPM server, php-fpm socket will listening on port 1780
docker run -it --rm --name=php-fpm -p 1780:1780 -v $(pwd):/app/public fbraz3/php-fpm:latest php-fpm

Step 2: Configure your webserver to handle fastcgi from 1780 port

  • Example for NGINX
server{listen80 default_server;root /app/public;indexindex.php index.html index.htm;location~\.php$ {fastcgi_pass127.0.0.1:1780;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param SCRIPT_NAME $fastcgi_script_name;include /etc/nginx/fastcgi_params;fastcgi_read_timeout300;}}
  • Example for Apache2 / HTTPD
<VirtualHost*:80>
ServerAdmin webmaster@localhost
DocumentRoot /app/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DirectoryIndex index.php index.html index.htm
<FilesMatch\.php$>
SetHandler "proxy:fcgi://127.0.0.1:1780"
</FilesMatch>
<Directory/app/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Source Code

fbraz3/php-fpm-docker

Web Server Images

Images providing PHP and built-in web server for easy deployment:

Usage

# Run a PHP-FPM server with Apache2, php-fpm socket will listening on port 80
docker run -it --rm --name=php-apache2 -p 80:80 -v $(pwd):/app/public fbraz3/php-apache2:latest php-fpm
# Run a PHP-FPM server with Nginx, php-fpm socket will listening on port 80
docker run -it --rm --name=php-nginx -p 80:80 -v $(pwd):/app/public fbraz3/php-nginx:latest php-fpm

Source Code

Full Stack images

Images providing a complete stack for your development environment:

  • LEMP: Classic LNMP/LEMP image, with Linux, Nginx, MySQL and PHP, plus with PHPMyAdmin.
  • LAMP: Classic LAMP image, with Linux, Apache2, MySQL and PHP, plus with PHPMyAdmin.

Usage

# Run a LEMP server, php-fpm socket will listening on port 80
docker run -it --rm --name=lnmp -p 80:80 -v $(pwd):/app/public fbraz3/lnmp:latest php-fpm
# Run a LAMP server, php-fpm socket will listening on port 80
docker run -it --rm --name=lamp -p 80:80 -v $(pwd):/app/public fbraz3/lamp:latest php-fpm

Source Code

Features

Cronjobs

Cronjobs can be configured by binding a file to /cronfile in the container. The system will automatically install and execute the jobs.

For more details, see the php-fpm-docker documentation.

Sending Mails

To enable email sending, this image relies on the configuration provided in the php-base-docker project.

Follow the instructions in the php-base-docker documentation to set up email functionality.

  • Compatibility with all images in this project.

Manage PHP Directives via Environment Variables

Some images allow you to customize PHP directives using environment variables.

For detailed instructions, refer to the php-fpm-docker documentation.

Build Status

Here's a summary of the images available in this project:

ImageBuild ScheduleBuild Status
php-cliEvery Sunday, 6:00 AM UTCBase Images
phalconEvery Sunday, 7:00 AM UTCPhalcon Images
php-composerEvery Sunday, 7:15 AM UTCBuild Composer Images
wp-cliEvery Sunday, 7:30 AM UTCWP-Cli Images
symfony-cliEvery Sunday, 7:40 AM UTCSymfony Images
php-fpmEvery Monday, 6:00 AM UTCBuild Base ImagesBuild Phalcon Images
php-nginxEvery Tuesday, 6:00 AM UTCBuild Base ImagesBuild Phalcon Images
php-apache2Every Tuesday, 9:00 AM UTCBuild Base ImagesBuild Phalcon Images
lemp/lnmpEvery Wednesday, 6:00 AM UTCBuild Base ImagesBuild Phalcon Images
lampEvery Wednesday, 9:00 AM UTCBuild Base ImagesBuild Phalcon Images

Donation

Maintaining this project requires significant time and effort. If you find it valuable, please consider supporting its development through a donation:

About

Docs for my PHP Docker Images

Topics

Resources

Contributing

Stars

21 stars

Watchers

1 watching

Forks

Sponsor this project

Used by

Contributors