Sign inSign up

deckapp/nginx_php

By deckapp

Updated over 5 years ago

Image
0

609

deckapp/nginx_php repository overview

Docker Squash to reduce the size of the final Docker image for PHP + Nginx

Carefully crafted Docker Squash to reduce the size of the final Docker image for PHP + Nginx with PHP 7.3, PHP 7.2, PHP 7.1, PHP 7.0, Nginx.

  • Fast and simple PHP extensions installation
  • Alpine base image with PHP.earth PHP repositories
  • Multiple PHP versions
  • runit for running multiple services without overhead
  • Optional Composer installation
  • Optional PHP installation
  • Optimized Docker image sizes

Docker tags

The following list contains all current Docker tags and what is included in each.

SystemDocker TagFeaturesSize
PHP 7.0.33@Alpine 3.7.37.0-nginxNginx 1.12.2, FPM
PHP 7.1.28@Alpine 3.9.37.1-nginxNginx 1.14.2, FPM
PHP 7.2.17@Alpine 3.9.37.2-nginxNginx 1.14.2, FPM
PHP 7.3.4@Alpine 3.9.37.3-nginxNginx 1.14.2, FPM
PHP 7.4.0alpha1@Alpine 3.9.47.4-nginxNginx 1.14.2, FPM

Quick usage

Nginx

Dockerfile for running Nginx HTTP server with PHP FPM:

FROM dockerstacks/nginx_php:v{PHP version}


### Composer

To install Composer:

```Dockerfile
FROM dockerstacks/nginx_php:v{PHP version}

RUN apk add --no-cache composer
PHPUnit

To install PHPUnit:

FROM dockerstacks/nginx_php:v{PHP version}

RUN apk add --no-cache phpunit
FROM dockerstacks/nginx_php:v{PHP version}

RUN apk add --no-cache php7.3-sodium php7.3-intl php7.3-pdo_mysql

or install them with pecl:

apk add --no-cache php7.3-dev gcc g++
pecl install {extension-name}
PHP ini settings

create application specific php.ini and copy the file into docker image:

# php.ini
memory_limit = 512M
FROM dockerstacks/nginx_php:v{PHP version}

COPY php.ini $PHP_INI_DIR/conf.d/my-app.ini
Docker Stack

Docker Stack is way of orchestration of Docker services and simplifies running multiple services of your application. In this example we'll run an Nginx web server with PHP 7.3 FPM with docker-compose.yml file. In a new project directory create a Dockerfile:

FROM dockerstacks/nginx_php:v{PHP version}

The docker-compose.yml file:

version: '3'

services:
  app:
    image: dockerstacks/nginx_php:v{PHP version}
    volumes:
      - .:/var/www/html
    ports:
      - mode: host
        target: 80
        published: 80

The index.php file:

<?php

phpinfo();

And there should be phpinfo() output visible on http://localhost. Make sure there isn't any other service listening on port 80 before running above command.

PHP 7.0, 7.1, PHP 7.2

To use older versions PHP 7.0, 7.1, or 7.2 use Docker images with 7.0, 7.1, or 7.2:

FROM dockerstacks/nginx_php:v{PHP version}

RUN apk add --no-cache composer

Tag summary

Content type

Image

Digest

Size

9.8 MB

Last updated

over 5 years ago

docker pull deckapp/nginx_php:v7.4