thecodingmachine / docker-images-php

A set of PHP Docker images
MIT License
791 stars 140 forks source link

How to manually build PHP extensions with the v3 images? #193

Open MrMage opened 4 years ago

MrMage commented 4 years ago

Happy user of the v2 images trying to migrate to v3 here. With v2, I built two custom PHP extensions using the following Dockerfile snippet:

FROM thecodingmachine/php:7.3-v2-apache as ext_builder
WORKDIR /var/www/html

RUN git clone --recursive --depth=1 https://github.com/kjdev/php-ext-zstd.git \
  && cd php-ext-zstd \
  && phpize \
  && ./configure \
  && make -j 6

RUN git clone --recursive --depth=1 https://github.com/census-instrumentation/opencensus-php.git \
  && cd opencensus-php/ext \
  && phpize \
  && ./configure \
  && make -j 6

However, according to https://github.com/thecodingmachine/docker-images-php/blob/v3/MIGRATING.md, the build environment is not included in the v3 images. And sure enough, the above steps fail at the phpize command with the v3 images.

Do you have any best practices on installing all the necessary build tools into these images? I am using a temporary "extension builder" image for building, so the build tools won't be part of my final image anyway.

I have looked at the existing issues, but could not find any relevant ones.

MrMage commented 4 years ago

Seems like I was able to install the necessary build tools now with the following command:

RUN sudo apt-get update \
  && sudo apt-get install -y --no-install-recommends build-essential php-pear php7.3-dev pkg-config \
  && sudo apt-get dist-upgrade -y --force-yes \
  && sudo apt-get autoremove -y \
  && sudo apt-get clean -y \
  && sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

However, it would be nice to have an "official" recommendation for this :-)

moufmouf commented 4 years ago

Yep, you are perfectly right. I'll keep the issue open until I find some time to properly document it.