phpearth / docker-php

🐳 Docker For PHP developers - Docker images with PHP, Nginx, OpenLiteSpeed, Apache, Lighttpd, and Alpine
https://docs.php.earth/docker
MIT License
261 stars 80 forks source link

Minimal/Bare image needed #6

Closed adaliszk closed 6 years ago

adaliszk commented 6 years ago

So I see that you install a bunch of modules for environments, but I don't see any image with only the least amount of modules installed. I would like to install the required modules myself instead having ~20 unused modules.

For high speed API-s it's necessary to drop any unused package/module from the production environment, because they are booting up by each request and taking away a huge chunk of runtime just by existing.

I see that I could add your repos to a bare alpine image, but I would like to have a bare image where the depo and base packages are already installed. I wish to install any module by myself instead having it preinstalled.

petk commented 6 years ago

Hello, after few testings, and checkings, now we have also small PHP CLI only images: phpearth/php:7.0, phpearth/php:7.1, and phpearth/php:7.2.

What is the best approach with these images and to have smallest possible sizes?

In case you really need a smallest optimized size to use, it's better to go after the PHP.earth Alpine repository and build them in custom manner: https://github.com/php-earth/alpine

FROM alpine:3.6

ENV \
    # When using Composer, disable the warning about running commands as root/super user
    COMPOSER_ALLOW_SUPERUSER=1 \
    # Persistent runtime dependencies
    DEPS="php7.1 \
          curl \
          ca-certificates"

# PHP.earth Alpine repository for better developer experience
ADD https://repos.php.earth/alpine/phpearth.rsa.pub /etc/apk/keys/phpearth.rsa.pub

RUN set -x \
    && echo "https://repos.php.earth/alpine" >> /etc/apk/repositories \
    && apk add --no-cache $DEPS

CMD ["php", "-a"]

And then start building and using them...:

docker build --no-cache -t vendor/php:7.1 -f Dockerfile .

That way you install only what you really need. The current images include some most used PHP extensions for using most of those today's frameworks and CMSes. Yes, some might be removed more, that's for sure. All in further checkings with docs coming up. I'll close this issue. In case you need further info or more support let us know. Thanks for reporting.

adaliszk commented 6 years ago

Thank you for the images! I usually using this bare images to add the actual features what needed for the projects, it's very useful to start from a "skratch" image where every tool is initialized then the server provider images also could work from the minimal so if the base image changes the other would also automatically.