craftcms / docker

Craft CMS Docker images.
104 stars 38 forks source link

Missing PHP extensions in Base image #53

Open thkus opened 2 years ago

thkus commented 2 years ago

Description

While running a deployment via gitlab-ci the latest base image craftcms/nginx:8.0 was pulled from Docker Hub. The subsequent composer install failed because several PHP extensions were suddenly missing. Has there been a change in the base image that caused this?

How could we possibly avoid changes like that? Is there a versioning in place so we can set fixed versions for the base images we use?

Problem 1
- Root composer.json requires PHP extension ext-simplexml * but it is missing from your system. Install or enable PHP's simplexml extension.

Problem 2
- craftcms/cms is locked to version 3.7.28 and an update of this package was not requested.
- craftcms/cms 3.7.28 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.

Steps to reproduce

  1. Create a Dockerfile which pulls the base image craftcms/nginx:8.0
  2. Run composer install

Additional info

jasonmccallister commented 2 years ago

Hi @thkus, I just ran the following to verify the extension is there and it shows up.

Can you run the following and provide the output?

docker run --rm --pull always --entrypoint php -it craftcms/nginx:8.0 -m
jasonmccallister commented 2 years ago

Just a few follow up items:

  1. How are you running composer? The craftcms/nginx:x images don't contain composer except the -dev images which are used for Nitro.
  2. If you are running composer in its own container, it has no extensions so you have to run composer install --ignore-platform-reqs
  3. Can you provide your Dockerfile
thkus commented 2 years ago

Hi @jasonmccallister,

thanks for the quick reply.

The output from docker run --rm --pull always --entrypoint php -it craftcms/nginx:8.0 -m is:

[PHP Modules]
bcmath
blackfire
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
imagick
intl
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
soap
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
blackfire

Our Dockerfile looks like this (stripped down, but reproducible):

FROM craftcms/nginx:8.0

# Be root
USER root

# Install build dependencies
RUN apk add --no-cache --virtual .build-deps composer 

# Copy code base
COPY --chown=www-data:www-data ./site /app

# Don't run composer as root
USER www-data

# Install dependencies
RUN composer install --prefer-dist --no-scripts --no-dev --no-interaction -d /app/

# Don't be root anymore
USER www-data

# Overwrite entrypoint
ENTRYPOINT [ "sh", "/etc/startup.sh" ]

It works when i manually install dependencies like so:

RUN apk add --no-cache mysql-client \
                        libxml2-dev \
                        php8-mbstring \
                        php8-xml \
                        php8-xmlreader \
                        php8-xmlwriter \
                        php8-pdo \
                        php8-dom \
                        php8-simplexml \
                        php8-fileinfo \
                        php8-tokenizer \
                        php8-gd \
                        libpng-dev \
                        libpng \
                        $PHPIZE_DEPS