Closed dcorrea777 closed 1 year ago
Try adding versions explicitly in Docker images:
FROM bref/php-82-fpm-dev:2
COPY --from=bref/extra-mongodb-php-82:1 /opt /opt
(this is for bref v2, if you are using bref v1 you need to use different versions)
(don't forget to docker pull
the images too, to get the latest versions)
@mnapoli Thanks for the answer, but I still have the same problem, my dockerfile looked like this:
FROM bref/php-82-fpm-dev:2
COPY --from=bref/extra-mongodb-php-82:1 /opt /opt
I deleted all my linux images and did the whole process again. Basically I did it in that order.
docker pull bref/php-82-fpm-dev:2
docker pull bref/extra-mongodb-php-82:1
docker build -t php-82-fpm-dev --no-cache .
My images
REPOSITORY TAG IMAGE ID CREATED SIZE
php-82-fpm-dev latest 201b4821d7a7 4 minutes ago 959MB
bref/extra-mongodb-php-82 1 23f4823d5b3b 3 days ago 9.44MB
bref/php-82-fpm-dev 2 c59b21c6b75c 13 days ago 949MB
mongo latest 9a5e0d0cf6de 2 weeks ago 646MB
When I access that container using the following command:
docker run -it --rm php-82-fpm-dev bash
And run a php -v
, the warning still appears
PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /opt/bref/extensions/mongodb.so (libssl.so.1.1: cannot open shared object file: No such file or directory), /opt/bref/extensions/mongodb.so.so (/opt/bref/extensions/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 8.2.4 (cli) (built: Apr 3 2023 09:43:33) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.4, Copyright (c) Zend Technologies
with Zend OPcache v8.2.4, Copyright (c), by Zend Technologies
I did the test on another machine with linux and had the same problem.
Note: In this example I did, I didn't even configure anything in the php project using composer, I just ran the docker images and accessed them, and I had this warning
I have the same problem for pcov
FROM bref/php-81-fpm-dev
COPY --from=bref/extra-pcov-php-81 /opt /opt
WORKDIR /var/task
if I build and run the container I get this
docker build -t bref_pcov2 .
docker run -it bref_pcov2 bash
bash-4.2# php -i | grep pcov
PHP Warning: PHP Startup: Unable to load dynamic library 'pcov.so' (tried: /opt/bref/lib/php/extensions/no-debug-non-zts-20210902/pcov.so (/opt/bref/lib/php/extensions/no-debug-non-zts-20210902/pcov.so: cannot open shared object file: No such file or directory), /opt/bref/lib/php/extensions/no-debug-non-zts-20210902/pcov.so.so (/opt/bref/lib/php/extensions/no-debug-non-zts-20210902/pcov.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
/opt/bref/etc/php/conf.d/ext-pcov.ini
php -m
PHP Warning: PHP Startup: Unable to load dynamic library 'pcov.so' (tried: /opt/bref/lib/php/extensions/no-debug-non-zts-20210902/pcov.so (/opt/bref/lib/php/extensions/no-debug-non-zts-20210902/pcov.so: cannot open shared object file: No such file or directory), /opt/bref/lib/php/extensions/no-debug-non-zts-20210902/pcov.so.so (/opt/bref/lib/php/extensions/no-debug-non-zts-20210902/pcov.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
bash-4.2#
Same results tagging the images:
FROM bref/php-81-fpm-dev:1.7.27
COPY --from=bref/extra-pcov-php-81:1.1.0 /opt /opt
WORKDIR /var/task
It works with bref 2 anyway
FROM bref/php-82-fpm-dev:2
COPY --from=bref/extra-pcov-php-82:1.1.0 /opt /opt
@mauroartizzu you have mixing Bref v1 with Bref v2 extra layers:
FROM bref/php-81-fpm-dev:1.7.27
COPY --from=bref/extra-pcov-php-81:1.1.0 /opt /opt
WORKDIR /var/task
☝️ this is invalid. Try using :0
for extra layers if you use Bref v1.
FROM bref/php-81-fpm-dev:1.7.27 COPY --from=bref/extra-pcov-php-81:1.1.0 /opt /opt WORKDIR /var/task
Thanks! It works
same error when testing a custom layer
PHP_VERSION=82 BREF_VERSION=2
FROM public.ecr.aws/lambda/provided:al2
COPY --from=bref/extra-mongodb-php-82:1.1.0 /opt /opt
... copy other extensions ...
layer=custom php_versions=82 make test
output of testing:
###############################################
###############################################
### Testing layers/extensions PHP82
###
Sending build context to Docker daemon 2.048kB
Step 1/5 : ARG PHP_VERSION
Step 2/5 : ARG TARGET_IMAGE
Step 3/5 : FROM bref/$TARGET_IMAGE AS ext
---> aedbf57f0c8e
Step 4/5 : FROM bref/php-$PHP_VERSION:2
---> 0e38ce64966d
Step 5/5 : COPY --from=ext /opt /opt
---> f191daba7edc
Successfully built f191daba7edc
Successfully tagged bref/test-layers/extensions-82:latest
Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /opt/bref/extensions/mongodb.so (libssl.so.1.1: cannot open shared object file: No such file or directory), /opt/bref/extensions/mongodb.so.so (/opt/bref/extensions/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
FAIL: Class "MongoDB\Driver\Manager" does not exist.
make: *** [test] Error 1
I think the reason is the required lib for the MongoDB extension is omitted
tried: /opt/bref/extensions/mongodb.so (libssl.so.1.1: cannot open shared object file: No such file or directory
add these lines below to the MongoDB extension Dockerfile and then rebuild it
# 1. add this line below
RUN php /bref/lib-copy/copy-dependencies.php /tmp/mongodb.so /tmp/extension-libs
# 2. add this line below
COPY --from=ext /tmp/extension-libs /opt/lib
after adding lines the Dockerfile for the MongoDB extension is like this:
ARG PHP_VERSION
ARG BREF_VERSION
FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext
RUN pecl install --force mongodb
RUN cp `php-config --extension-dir`/mongodb.so /tmp/mongodb.so
RUN echo 'extension=mongodb.so' > /tmp/ext.ini
# 1. add this line below
RUN php /bref/lib-copy/copy-dependencies.php /tmp/mongodb.so /tmp/extension-libs
# Build the final image with just the files we need
FROM scratch
# Copy things we installed to the final image
COPY --from=ext /tmp/mongodb.so /opt/bref/extensions/mongodb.so
COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/ext-mongodb.ini
# 2. add this line below
COPY --from=ext /tmp/extension-libs /opt/lib
I encounters issues with the MongoDB extension, after I upgraded bref 2.0.2 to bref 2.0.3. I got exceptions in cloudwatch
Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /opt/bref/extensions/mongodb.so
2023-04-21T06:16:04.949Z INIT_START Runtime Version: provided:al2.v17 Runtime Version ARN: arn:aws:lambda:eu-west-1::runtime:f35635a04216ba4e6a0e74d3c2db080d443709a8f3f2e71fedf54a4f8756705d
2023-04-21T06:16:05.184Z Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /opt/bref/extensions/mongodb.so (libssl.so.1.1: cannot open shared object file: No such file or directory), /opt/bref/extensions/mongodb.so.so (/opt/bref/extensions/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
After I downgraded to Bref 2.0.2 the issue went away. In both cases I used bref extensions 1.1.0. There where no user code changes in the upgrade. The Lambda Layer used are idential for the extensions, only the php layer was upgraded, from version 31 to version 33:
The layers is updated in https://github.com/brefphp/bref/pull/1510/files#diff-1918edee943d6601143ac98ac95da06709c1c6284021cb7f8ffe7c48de9e6db6R6 and refers to https://github.com/brefphp/aws-lambda-layers/releases/tag/2.0.8 which does not seem to be that spectacular, I only see PHP 8.2.5 and xml lib upgrade...
I will continue investigating!
So, I'm seeing sort of the same issue.
We are using php-81-fpm
which now loads layer version 44 (arn:aws:lambda:eu-west-1:534081306603:layer:php-81-fpm:44
) and mongo layer version 8 (arn:aws:lambda:eu-west-1:403367587399:layer:mongodb-php-81:8
). We had to downgrade to layer version 42 (arn:aws:lambda:eu-west-1:534081306603:layer:php-81-fpm:42
) to get things working again. We got the following error:
PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /opt/bref/extensions/mongodb.so (libssl.so.1.1: cannot open shared object file: No such file or directory), /opt/bref/extensions/mongodb.so.so (/opt/bref/extensions/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Versions 43 and 44 seem to break things. This is the case with both bref/bref versions 2.0.2 and 2.0.3.
docker build --build-arg PHP_VERSION=82 --build-arg TARGET_IMAGE=extra-mongodb-php-82:latest -t bref/test tests
[+] Building 1.3s (8/8) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 38B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/bref/php-82-fpm-dev:2 0.8s
=> [internal] load metadata for docker.io/bref/extra-mongodb-php-82:latest 1.2s
=> [ext 1/1] FROM docker.io/bref/extra-mongodb-php-82:latest@sha256:50b99e09e0b5bc63d1f99a09d8dabae41dceece60f7affd89b401d1eae63313b 0.0s
=> [stage-1 1/2] FROM docker.io/bref/php-82-fpm-dev:2@sha256:35e2e1445e9ec35897d9a04eba027283236d2e4f938f0a9953600f939c4203df 0.0s
=> CACHED [stage-1 2/2] COPY --from=ext /opt /opt 0.0s
=> exporting to image 0.1s
=> => exporting layers 0.0s
=> => writing image sha256:293872c6cdece8afe659b1d8f2092fb42011d0995df39d286c44d7b604532b16 0.0s
=> => naming to docker.io/bref/test-mongodb2-82 0.0s
docker run --entrypoint= --rm -v /home/:/var/task bref/test php /var/task/test.php
PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /opt/bref/extensions/mongodb.so (libssl.so.1.1: cannot open shared object file: No such file or directory), /opt/bref/extensions/mongodb.so.so (/opt/bref/extensions/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
FAIL: Class "MongoDB\Driver\Manager" does not exist.
I was able to resolve this issue by re-building the mongodb layer using this source code and using that instead.
git clone ....
make test
layer=mongodb php_versions=82 only_region=us-east-1 make publish
Interesting, Bref 2.0.3 also includes these changes: https://github.com/brefphp/aws-lambda-layers/releases/tag/2.0.7
It is probably related to the OpenSSL upgrade: libssl.so.1.1: cannot open shared object file
. OK so we need to rebuild the layer and it should be good.
I've opened #436 to try and do that.
Thanks all for investigating!
Probably there are more than just this extension that need to be re-built, that were linking against openssl.
Still getting the error, mongo driver isn't loaded. Do we have any ETA on the fix please, or what can we do to help to solve the issue?
I just tried the updated mongodb layer (version 7 for php 8.2) and that one works:
arn:aws:lambda:eu-west-1:403367587399:layer:mongodb-php-82:7
Thanks for all the support on this!
Hello everybody, I think the problem is not solved on php 8.1 on latest layer for mongodb extension, what is the best way to fix that? I can help on this if needed.
It is on the latest build. Make sure you have the latest bref and bref extensions packages installed. composer outdated
can quickly highlight errors for you.
@wysow php 8.1 should have been fixed too, make sure you are on the latest versions
Hum... simply updating bref/bref composer does not want to put it on version 2.04 and forcing an update to bref version 2.0.4 is giving me this log :
Loading composer repositories with package information Updating dependencies
Lock file operations: 0 installs, 1 update, 1 removal
- Removing crwlr/query-string (v1.0.1)
- Upgrading bref/bref (2.0.2 => v2.x-dev a43f977)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 1 removal
- Downloading bref/bref (v2.x-dev a43f977)
- Removing crwlr/query-string (v1.0.1)
- Upgrading bref/bref (2.0.2 => v2.x-dev a43f977): Extracting archive
Weird isn't it?
Hum... simply updating bref/bref composer does not want to put it on version 2.04 and forcing an update to bref version 2.0.4 is giving me this log :
Loading composer repositories with package information Updating dependencies Lock file operations: 0 installs, 1 update, 1 removal - Removing crwlr/query-string (v1.0.1) - Upgrading bref/bref (2.0.2 => v2.x-dev a43f977) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 0 installs, 1 update, 1 removal - Downloading bref/bref (v2.x-dev a43f977) - Removing crwlr/query-string (v1.0.1) - Upgrading bref/bref (2.0.2 => v2.x-dev a43f977): Extracting archive
Weird isn't it?
Just tried with that and bref extensions on the latest version and same problem...
Try updating all dependencies or upgrading crwlr/query-string
first.
@GrahamCampbell just tried to re-update bref/bref and now that worked as expected, bref/bref is now at 2.0.4 version. Thanks!
Will now try if mongodb extension is correctly loaded.
OK it's working as expected now... Can't really know why I got all this weird behaviors...
You got that behaviour because you were not using the latest package, and then you were unable to upgrade to the latest because you were not allowing the peer dependency crwlr/query-string
to upgrade.
I have the following dockerfile
After I compile my dockerfile and run it from the command line, I get the following warning:
When I run the command
ls -la
in the path/opt/bref/extensions
the mongodb.so file is there.But for some reason it doesn't find that extension in that path
When I run the
php -m
command it also doesn't show the mongo extension being loaded.