Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.
/ nginx-php-docker Public archive

A lightweight combined Nginx/PHP-FPM Docker image.

License

Notifications You must be signed in to change notification settings

komandar/nginx-php-docker

Repository files navigation

Nginx/PHP-FPM Docker Image

A lightweight combined Nginx/PHP-FPM Docker image.

Build Status Image Size Docker Pulls Licence

Features

The following features work out of the box without any configuration:

  • Nginx serves as the web host and reverse proxy
  • PHP-FPM/OPcache for fast performance in the browser and on the CLI
  • composer is installed and ready to use to setup all your dependencies
  • mysql_pdo is installed as the driver for MariaDB/Mysql connections
  • pgsql_pdo is installed as the driver for PostgreSQL connections
  • gd is installed for image processing
  • zip is installed for items that may need that

Platforms

This image offers platform support for the following architectures:

  • linux/amd64
  • linux/arm64
  • linux/arm/v7

Install

# Dockerfile
FROM: komandar/nginx-php:latest

# docker-compose
image: komandar/nginx-php:latest

Usage

Vanilla PHP and HTML

Place your PHP or HTML site files into /var/www/app/public inside the container to get started with this image. This can be achieved by using a volume in a docker-compose file or by copying them over in a Dockerfile. If you are using HTML instead of PHP, ensure you remove the index.php file so that your index.html file can take priority.

Laravel

Place the root of your laravel project in /var/www/app so that the public folder of laravel lines up with the directory served by this nginx image (see examples/laravel for more details).

Want to give this image a spin? Simply run the following:

docker compose up -d

Once the container spins up, navigate to http://localhost:8888 in a browser.

Docker Tags

Tags for this image follow the syntax of PHP_VERSION[:IMAGE_TYPE]; for instance, a valid tag would be 8.1 signifying to use PHP v8.1 of this image.

PHP Versions

  • 8.1 - uses the latest release on the PHP 8.1 Alpine track.

Standalone Tags

  • latest - uses the latest release of this image.

Development

Note: Alpine Linux does not keep old versions of packages. This image pins to the relative major version to try staying flexibile. Future builds may need to be altered if packages are no longer offered.

# Test nginx configuration
nginx -T

Releasing

When releasing this project, push to the branch related to the php version.

Building New Versions

This image supports swapping in the version number of PHP with a value from the official PHP-FPM Alpine tag list.

Automated Builds

GitHub Actions will automatically build and push supported tags to Docker Hub on each new release. Additionally GitHub Actions will automatically build the latest tag on any push to the main branch. It is highly recommended that you use a versioned release of this image to avoid any transient changes introduced in any given latest build.

Manual Builds

docker build -t komandar/nginx-php:8.1 --build-arg PHP_VERSION=8.1 .
docker push komandar/nginx-php:8.1