/php-and-nginx

Lightweight container with Nginx & PHP-FPM 7.x based on Alpine Linux.

Primary LanguageDockerfileMIT LicenseMIT

Published

PHP And Nginx Docker image

This image was built based on the scripts that I have found at docker-alpine-micro , and with the help of his docker-utils script I was able to build my own image.

This is still new/simple docker image which will have:

  1. PHP7.x/8.x
  2. Nginx (with h5bp)

Versions available

  1. zaherg/php-and-nginx:7.2 Not active any more
  2. zaherg/php-and-nginx:7.3 Not active any more
  3. zaherg/php-and-nginx:7.4
  4. zaherg/php-and-nginx:8.0

These images were also published to github packages

Latest will always be used with the latest PHP version

NOTE:

  1. Starting from 2020, We have removed crond and rsyslogd and they wont be installed nor activated any more.
  2. Also we removed xdebug as it is pointless to have it.

Using php-and-nginx as your base image

This is a sample docker file which is used to build Laravel Application

FROM zaherg/php-and-nginx:8.0

ENV APP_ENV production

COPY . /web/html

WORKDIR /web/html

RUN composer install  --prefer-dist --no-ansi --no-interaction --no-scripts --no-progress --no-suggest --optimize-autoloader --no-dev \
	&& sed -i 's/root \/web\/html;/root \/web\/html\/public;/' /etc/nginx/nginx.conf \
	&& chgrp -R nobody /web/html/storage /web/html/bootstrap/cache \
    && chmod -R ug+rwx /web/html/storage /web/html/bootstrap/cache \
    && chown -R nginx /web/html/storage /web/html/bootstrap/cache

We copy the code to the /web/html, since the root location for my web pages defined inside nginx configuration as web/html we run a small sed command to replace it with the root location for our Laravel application

sed -i 's/root \/web\/html;/root \/web\/html\/public;/' /etc/nginx/nginx.conf

Small note: The user we use here is root feel free to change it.

Zend OPcache

You can manage Zend OPcache using the environment variables

PHP_OPCACHE_VALIDATE_TIMESTAMPS=0
PHP_OPCACHE_MAX_ACCELERATED_FILES=10000
PHP_OPCACHE_MEMORY_CONSUMPTION=192
PHP_OPCACHE_MAX_WASTED_PERCENTAGE=10

PHP Modules

  1. Core
  2. ctype
  3. curl
  4. date
  5. dom
  6. fileinfo
  7. filter
  8. ftp
  9. hash
  10. iconv
  11. json
  12. libxml
  13. mbstring
  14. mysqlnd
  15. openssl
  16. pcre
  17. PDO
  18. pdo_sqlite
  19. Phar
  20. posix
  21. readline
  22. Reflection
  23. session
  24. SimpleXML
  25. SPL
  26. sqlite3
  27. standard
  28. tokenizer
  29. xml
  30. xmlreader
  31. xmlwriter
  32. zlib

GD information

GD Support => enabled
GD Version => bundled (2.1.0 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.8.1
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 8
PNG Support => enabled
libPNG Version => 1.6.34
WBMP Support => enabled
XBM Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.