Sign inSign up

ashsmith/php

By ashsmith

Updated over 6 years ago

Generic PHP images, based on alpine, with useful extensions.

Image
1

10K+

ashsmith/php repository overview

The purpose of this is to provide a generic PHP base image that can be shared across projects. It won't matter if you're running Magento, Laravel, Wordpress, or Craft CMS, etc. You'll have a consistent base image that provides a number of tools built in, and sensible php extensions.

These images are designed to be used in production, as well as in a staging/local environments.

Images available:

  • ashsmith/php:7.1-fpm-alpine
  • ashsmith/php:7.1-cli-alpine
  • ashsmith/php:7.2-fpm-alpine
  • ashsmith/php:7.2-cli-alpine
  • ashsmith/php:7.3-fpm-alpine
  • ashsmith/php:7.3-cli-alpine

Images with xdebug preinstalled & enabled:

  • ashsmith/php:7.1-fpm-xdebug-alpine
  • ashsmith/php:7.1-cli-xdebug-alpine
  • ashsmith/php:7.2-fpm-xdebug-alpine
  • ashsmith/php:7.2-cli-xdebug-alpine
  • ashsmith/php:7.3-fpm-xdebug-alpine
  • ashsmith/php:7.3-cli-xdebug-alpine

Deprecated tags (only alpine is being actively developed):

  • ashsmith/php:7.1-fpm
  • ashsmith/php:7.1-cli
  • ashsmith/php:7.2-fpm
  • ashsmith/php:7.2-cli

How to build these images locally:

docker-compose build

How to add additional packages in your own dockerfile:

You will need to reconfigure to use the root user, then switch back afterwards to the app user.

FROM ashsmith/php:7.2-fpm-alpine

USER root
RUN apk add myawesomepackage
USER app:app

What PHP extensions come out of the box?

  • xdebug (only if you use the xdebug tag variant!)
  • gd
  • intl
  • mbstring
  • pdo_mysql
  • xsl
  • zip
  • soap
  • bcmath
  • mcrypt
  • pcntl

My goal is to provide some commonly used extensions, and speed up build times by not needing to recompile PHP multiple times.

What else is there?

Composer, of course!

Why do you use an app user instead of root?

TL;DR; Security.

Read up on it here: Processes in containers should not run as root

So how can I use this!?

docker run ashsmith/php:7.2-fpm-alpine -v $(pwd):/var/www/html -p 9000:9000 --name myawesomephpapp

Or if you like to use docker-compose:

version: "3.0"

services:
  cli:
    image: ashsmith/php:7.2-cli-alpine
    volumes:
      - ./src:/var/www/html:delegated

  phpfpm:
    image: ashsmith/php:7.2-fpm-alpine
    volumes:
      - ./src:/var/www/html:delegated

  nginx:
    image: ashsmith/nginx:latest-phpfpm
    environment:
      - FPM_HOST=phpfpm
    links:
      - phpfpm
    ports:
      - 80:80
    volumes:
      - ./src:/var/www/html:delegated

Then:

docker-compose up -d

Want to run one of commands?

docker-compose run --rm cli composer install

OpCache

opcache is enabled by default!

For local development I recommend mounting a new php .ini file to explicitly disable opcache.

Tag summary

Content type

Image

Digest

Size

127.9 MB

Last updated

over 6 years ago

docker pull ashsmith/php:7.3-fpm