magento / magento-cloud-docker

All Submissions you make to Magento Inc. (“Magento") through GitHub are subject to the following terms and conditions: (1) You grant Magento a perpetual, worldwide, non-exclusive, no charge, royalty free, irrevocable license under your applicable copyrights and patents to reproduce, prepare derivative works of, display, publically perform, sublicense and distribute any feedback, ideas, code, or other information (“Submission") you submit through GitHub. (2) Your Submission is an original work of authorship and you are the owner or are legally entitled to grant the license stated above. (3) You agree to the Contributor License Agreement found here: https://github.com/magento/magento2/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT.html
Open Software License 3.0
256 stars 192 forks source link

php ext-sodium missing for 7.4-cli which is required for Magento 2.4.3 #329

Closed Morgy93 closed 2 years ago

Morgy93 commented 3 years ago

Overview

The php extension ext-sodium is missing for magento/magento-cloud-docker-php: 7.4-cli-1.2.4 which is a requirement for Magento 2.4.3 to build. Also reported here: https://github.com/magento/magento2/issues/33743

Preconditions

Magento 2.4.3 magento/magento-cloud-docker-php: 7.4-cli-1.2.4 (latest)

Steps to reproduce

  1. Use docker image magento/magento-cloud-docker-php:7.4-cli-1.2.4
  2. Try to build any Magento 2.4.3

Expected result

Build should succeed.

Actual result

Short:

magento/product-community-edition 2.4.3 requires web-token/jwt-framework ^v2.2.7

web-token/jwt-framework v2.2.10 requires ext-sodium *

Long:

Your lock file does not contain a compatible set of packages. Please run composer update.
  Problem 1
    - web-token/jwt-framework is locked to version v2.2.10 and an update of this package was not requested.
    - web-token/jwt-framework v2.2.10 requires ext-sodium * -> it is missing from your system. Install or enable PHP's sodium extension.
  Problem 2
    - web-token/jwt-framework v2.2.10 requires ext-sodium * -> it is missing from your system. Install or enable PHP's sodium extension.
    - magento/product-community-edition 2.4.3 requires web-token/jwt-framework ^v2.2.7 -> satisfiable by web-token/jwt-framework[v2.2.10].
    - magento/product-community-edition is locked to version 2.4.3 and an update of this package was not requested.
To enable extensions, verify that they are enabled in your .ini files:
    - 
    - /usr/local/etc/php/conf.d/blackfire.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-bz2.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-calendar.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-exif.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-gettext.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-intl.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-mysqli.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-redis.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-soap.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-sockets.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-sysvmsg.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-sysvsem.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-sysvshm.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
    - /usr/local/etc/php/conf.d/gnupg.ini
    - /usr/local/etc/php/conf.d/zz-magento.ini
    - /usr/local/etc/php/conf.d/zz-mail.ini
    - /usr/local/etc/php/conf.d/zz-pcov-settings.ini
    - /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
oshmyheliuk commented 3 years ago

@Morgy93 Hi,

Did you check that sodium extension is added to the list of extensions of your docker-compose.yaml file? It should be something like that:

 generic:
    hostname: generic.magento2.docker
    image: 'magento/magento-cloud-docker-php:7.4-cli-1.2.4'
    env_file: ./.docker/config.env
    environment:
      - 'PHP_EXTENSIONS=bcmath ..... sodium'
Morgy93 commented 3 years ago

@oshmyheliuk Thanks for your reply! Actually I'm using this for a GitLab Runner with .gitlab-ci.yml While providing PHP_EXTENSIONS with sodium manually works fine, I think it should be included by default, shouldn't it? Since it is a default requirement by Magento 2.4.3 and all~

YPyltiai commented 3 years ago

@Morgy93 images are used for multiple versions though and I am pretty sure in older versions it was conflicting with the other extension that was used instead. It makes sense to bundle it into PHP 7.4+ though, since these versions were not available at the time of transition to Sodium, so they won't have issues most likely.

dshevtsov commented 3 years ago

I have stuck into the same issue when running locally

curl https://raw.githubusercontent.com/magento/magento-cloud-docker/1.2.4/bin/init-docker.sh | bash -s -- --php 7.4

onto a fresh 2.4.3 template.

andriyShevtsov commented 3 years ago

I can't reproduce this issue with templates:

` environment:

andriyShevtsov commented 3 years ago

By default we have it in magento.app.yaml

runtime:
    extensions:
        - xsl
        - json
        - newrelic
        - sodium

If this extension wasn't added such error occurs.

cam-nisimura commented 3 years ago

I have stuck into the same issue when running locally

curl https://raw.githubusercontent.com/magento/magento-cloud-docker/1.2.4/bin/init-docker.sh | bash -s -- --php 7.4

onto a fresh 2.4.3 template.

init-docker.sh uses the docker image tagged "magento/magento-cloud-docker-php:${PHP_VERSION}-cli-${IMAGE_VERSION}". And php-cli-7.2, php-cli-7.3... do NOT include the sodium extension in the proper way.

joeshelton-wagento commented 3 years ago

The init-docker.sh script is my concern. Right now it can't install recent versions of Magento. Is there an easy way to enable all PHP extensions in the container? Something like PHP_EXTENSIONS=all? I worked around the issue using the command below, but it's very wordy.

docker run --rm -e "MAGENTO_ROOT=/app" -e "PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl sodium" -v "$(pwd)":/app -v ~/.composer/cache:/composer/cache "magento/magento-cloud-docker-php:7.4-cli-1.2.4" composer install --ansi
andriyShevtsov commented 3 years ago

@BaDos may you please take a look?

joeshelton-wagento commented 3 years ago

I see in the 1.2.2 release notes...

Sodium enabled by default—Enabled the sodium PHP extension by default within PHP Docker images.

https://devdocs.magento.com/cloud/release-notes/mcd-release-notes.html#v122

So, was this a regression? Or, was sodium removed on purpose?

I think ideally, if PHP_EXTENSIONS is not defined, the base Magento PHP extension requirements should be enabled. Basically...

PHP_EXTENSIONS="bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl sodium"

...should be a default value within the images.

Axel29 commented 3 years ago

Same problem here, I'm forced to use a --ignore-platform-reqs on my composer install command to get a fresh install of Magento withou having to use a docker-compose.yml file.

The image is meant to be used as a standalone image, thus it should have all the requirements of Magento such as sodium.

amansilla commented 2 years ago

Having the same issue today! Here is my workaround for being able to execute composer install.

docker run -it -v $(pwd):/app -w /app magento/magento-cloud-docker-php:7.4-cli-1.2.1 bash -c 'docker-php-ext-enable sodium && composer install'

@Axel29 this way you can avoid using the --ignore-platform-reqs flag which should be always avoided, otherwise wrong incompatible may be installed.

YPyltiai commented 2 years ago

@amansilla , you should try modifying command to just use recent containers instead of 1.2.1. If that still doesn't work - we will look at it additionally.

CC: @BaDos

Axel29 commented 2 years ago

@amansilla , you should try modifying command to just use recent containers instead of 1.2.1. If that still doesn't work - we will look at it additionally.

CC: @BaDos

@YPyltiai I tried it on the php7.4-cli-1.3.0 and it didn't work.

amansilla commented 2 years ago

@amansilla , you should try modifying the command to just use recent containers instead of 1.2.1. If that still doesn't work - we will look at it additionally.

CC: @BaDos

Sorry for that, in fact I've tested both magento/magento-cloud-docker-php:7.4-cli-1.2.1 and magento/magento-cloud-docker-php:7.4-cli-1.3.0 and in both cases the extension is missing.

YPyltiai commented 2 years ago

@BaDos , could you please take a look? I would expect https://github.com/magento/magento-cloud-docker/blob/develop/images/php/7.4-fpm/Dockerfile#L124-L135 had to install it by default but not clear why it doesn't happen.

BaDos commented 2 years ago

Hi! All PHP images contain a lot of extensions, including sodium.

But these extensions are disabled by default, and we enable them only if PHP_EXTENSIONS contains some of them

For example, the template has sodium extension: https://github.com/magento/magento-cloud/blob/2.4.3/.magento.app.yaml#L18 When you run ./vendor/bin/ece-docker build:compose this command reads .magento.app.yaml and generates the correct docker-compose.yaml file with sodium

BaDos commented 2 years ago

We can add a new option to init-docker.sh such as --ext to provide a list of needed extensions.

dshevtsov commented 2 years ago

Only optional extensions are expected to be configurable. Required extensions are expected to be up and working by default in a corresponding template.

Axel29 commented 2 years ago

Hi! All PHP images contain a lot of extensions, including sodium.

But these extensions are disabled by default, and we enable them only if PHP_EXTENSIONS contains some of them

For example, the template has sodium extension: https://github.com/magento/magento-cloud/blob/2.4.3/.magento.app.yaml#L18 When you run ./vendor/bin/ece-docker build:compose this command reads .magento.app.yaml and generates the correct docker-compose.yaml file with sodium

Hello @BaDos ,

It doesn't really make sense to disable sodium by default, as the image is meant to be used for many commands, not only as a docker-compose service.

For example, in the official documentation, at the Run Composer with Docker, it is suggested to use the following command to run composer:

docker run -it  -v $(pwd):/app/:delegated -v ~/.composer/:/root/.composer/:delegated magento/magento-cloud-docker-php:7.3-cli-1.1 bash -c "composer install&&chown www. /app/"

but this wouldn't use a docker-compose file, thus it won't read any "PHP_EXTENSIONS" line from it.

Since libsodium is a required extension for Magento, it should be (in my opinion) enabled by default in all of Magento Cloud Docker PHP images

BaDos commented 2 years ago

@dshevtsov

Only optional extensions are expected to be configurable. Required extensions are expected to be up and working by default in a corresponding template.

init-docker.sh does not read files form templates

@Alex29 I have checked our images/code We are trying to support all Magento versions. Previous time there was a conflict when sodium was enabled by default. MCD 1.3.1 will have enabled sodium by default.

Thank you for your contribution and for raising this issue!

BaDos commented 2 years ago

This issue will be fixed as part of internal task MCLOUD-8364 and will be added in the next release of MCD 1.3.1

dunagan5887 commented 2 years ago

@BaDos When will MCD 1.3.1 be available?

BaDos commented 2 years ago

@dunagan5887 hello!

We going to release MCD 1.3.1 in ~ a few weeks

dunagan5887 commented 2 years ago

@BaDos I'm currently testing the Docker PHP CLI 7.4-cli-1.3.1 image (linked here: https://hub.docker.com/layers/magento/magento-cloud-docker-php/7.4-cli-1.3.1/images/sha256-0c91371f027bb0fa5515b6e1cf32346d5c0fb39523f0e5a918e153dda13e36b3?context=explore) and still seeing sodium not being installed on CLI commands. Is this the version which was supposed to address this issue?