docker-library / php

Docker Official Image packaging for PHP
https://php.net
MIT License
3.82k stars 2k forks source link

Deploy Laravel with GitlabCI failed on mcrypt extension #531

Closed polaroi8d closed 6 years ago

polaroi8d commented 6 years ago

I would like to deploy my project on Gitlab CI with a yaml file. Dumped the following error log when I tried to install php extensions...

$ docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache
error: /usr/src/php/ext/mcrypt does not exist

usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
   ie: /usr/local/bin/docker-php-ext-install gd mysqli
       /usr/local/bin/docker-php-ext-install pdo pdo_mysql
       /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop

if custom ./configure arguments are necessary, see docker-php-ext-configure

Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip

Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
ERROR: Job failed: exit code 1

I tried to add apt-get install mcrypt php7.0-mcrypt but nothing happend. Anyone has a suggestion?

bweston92 commented 6 years ago

Hi @polaroi8d can you provide the base image name you're using?

polaroi8d commented 6 years ago

Hello @bweston92 I am always using the latest image from https://hub.docker.com/r/library/php/ with the command of image: php:latest

bweston92 commented 6 years ago

Ok by looking at the registry php:latest is php:7.2, mcrypt is no longer supported in PHP 7.2

polaroi8d commented 6 years ago

Ohhh, I don't know it. What is the last version of php where mcrypt is supported? @bweston92

bweston92 commented 6 years ago

PHP 7.1 Find out more here: https://wiki.php.net/rfc/mcrypt-viking-funeral

polaroi8d commented 6 years ago

Thanks for the help @bweston92 I am really appreciate for your help

thomasvargiu commented 6 years ago

In PHP 7.2 you can install mcrypt via PECL

geneowak commented 5 years ago

In PHP 7.2 you can install mcrypt via PECL

And how do you add it in the php.ini or to the image?

Build process completed successfully Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20170718/mcrypt.so' install ok: channel://pecl.php.net/mcrypt-1.0.1 configuration option "php_ini" is not set to php.ini location You should add "extension=mcrypt.so" to php.ini

Because after that you get this Step 7/9 : RUN docker-php-ext-install mcrypt pdo pdo_mysql zip ---> Running in e789ef243e8b error: /usr/src/php/ext/mcrypt does not exist

geneowak commented 5 years ago

Turns out I didn't have to update the php.ini file... I removed mcrypt from docker-php-ext-install and just added these lines

RUN pecl install mcrypt-1.0.1
RUN docker-php-ext-enable mcrypt

and it run without giving me an error. I was creating an image to run a Laravel 5.7 application (which I think still needs mcrypt) using the CI of gitlab. The image was created successfully and the tests run well.

Many thanks.