Hi,
we are getting the below issue on the alpine image:
Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Cannot create SSL client. SSL is not enabled in this build. in /var/www/myproject/vendor/mongodb/mongodb/src/Client.php:87
using
FROM php:7.2-fpm-alpine
WORKDIR /var/www
RUN apk add --no-cache --virtual .ext-deps \
autoconf \
g++ \
make \
pkgconf \
libssl1.0 \
&& pecl install \
redis \
mongodb \
&& docker-php-ext-enable \
redis \
mongodb \
&& apk del .ext-deps
RUN pecl config-set php_ini /etc/php.ini
# Copy project files
COPY . /var/www/myproject/
We also tried without libssl1.0 as libressl seem to install it on the base build and several other things without being able to solve this.
Works fine on 7.2-fpm-stretch
FROM php:7.2-fpm-stretch
WORKDIR /var/www
RUN apt-get update && apt-get install --no-install-recommends -y \
g++ \
pkg-config \
libssl-dev \
&& pecl install \
mongodb \
redis \
&& docker-php-ext-enable \
mongodb \
redis \
&& pecl config-set php_ini /etc/php.ini \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy project files
COPY . /var/www/myproject/
This is an error output by MongoDB https://github.com/doctrine/DoctrineMongoDBBundle/issues/452#issuecomment-371172879
The exception with message "Cannot create SSL client. SSL is not enabled in this build." originates in phongo_manager_init() when MONGOC_ENABLE_SSL is not defined.
https://github.com/FriendsOfSymfony/FOSUserBundle/issues/2786
with apt-get install php7.2-mongodb it install it correctly with SSL and other options enabled.
If you have further questions you should ask the Docker Community Forums, the Docker Community Slack, or Stack Overflow. As these repositories are for issues with the image and not necessarily for questions of usability
libssl1.0 in Alpine is just the shared library (ie needed at runtime), and not the development headers needed for linking. From the output of pecl install mongodb:
configure: checking whether OpenSSL is available
checking for PHP_MONGODB_SSL... no
checking for EVP_DigestInit_ex in -lcrypto... no
configure: checking whether OpenSSL >= 1.1.0 is available
checking for OPENSSL_init_ssl in -lssl... no
configure: checking whether OpenSSL < 1.1.0 is available
checking for SSL_library_init in -lssl... no
configure: checking whether LibreSSL is available
checking for PHP_MONGODB_SSL... no
checking for EVP_DigestInit_ex in -lcrypto... no
checking for tls_init in -ltls... no
checking which TLS library to use... no
checking whether to use system crypto profile... no
checking deprecated option for whether to use system crypto profile... no
So swapping libssl1.0 to openssl-dev:
configure: checking whether OpenSSL is available
checking for PHP_MONGODB_SSL... yes
And you'll want to make sure libssl1.0 stays installed and not removed as a dependency of openssl-dev with the apk del .ext-deps.
@yosifkit thanks for you comment it solved our issue:
FROM php:7.2-fpm-alpine
WORKDIR /var/www
RUN apk add --no-cache \
libssl1.0 \
&& apk add --no-cache --virtual .ext-deps \
autoconf \
g++ \
make \
openssl-dev \
&& pecl install \
redis \
mongodb \
&& docker-php-ext-enable \
redis \
mongodb \
&& apk del .ext-deps \
&& pecl config-set php_ini /etc/php.ini
# Copy project files
COPY . /var/www/myproject/
Most helpful comment
@yosifkit thanks for you comment it solved our issue: