Conversation
| ARG OL_VERSION=8 | ||
| ARG IC_VERSION=21 | ||
| # Oracle Instant Client image | ||
| FROM public.ecr.aws/docker/library/oraclelinux:$OL_VERSION AS oracle_base |
There was a problem hiding this comment.
Have you tested the layer? Here the library is installed in an image that is not the one used in AWS Lambda, there's high risk the library is incompatible when running in Lambda.
There was a problem hiding this comment.
I did. I created a custom layer and ran it with arn:aws:lambda:us-west-2:873528684822:layer:php-84:16. It connected and queried an Oracle database happily. I even tried it with the v2 layer (al.2) - which failed due to an incompatible lib. I totally get if you're not comfortable approving this PR. It could certainly have some sneaky issues. I'm happy to keep using my custom layer until you or the previous maintainer can get around to updating it :)
There was a problem hiding this comment.
Yes — I tested this in a real AWS Lambda environment and it works correctly.
I built a custom OCI8 layer and deployed it in a Lambda running Bref 3 on Amazon Linux 2023. The function successfully connects and executes queries against an Oracle database using oci_connect().
The Dockerfile is parameterized, so the same build works for PHP 8.3+ (8.3 / 8.4 / 8.5) by simply changing the PHP_VERSION build argument.
Example:
docker build
–build-arg PHP_VERSION=83
–build-arg BREF_VERSION=v3
-t oci8-layer .
Then the /opt directory is extracted and packaged as a Lambda layer.
After attaching the layer to the Lambda function and setting:
LD_LIBRARY_PATH=/opt/lib
OCI8 works correctly in the Lambda runtime.
One important thing I discovered during testing:
Oracle Instant Client 23.26 caused PHP-FPM crashes in Lambda.
The extension loaded correctly (it appeared in phpinfo()), but any call to oci_connect() triggered:
Error communicating with PHP-FPM to read the HTTP response.
Bref will restart PHP-FPM now.
CloudWatch logs showed the PHP-FPM worker exiting.
After switching to Oracle Instant Client 21.12, the problem disappeared and OCI8 worked perfectly.
Another small issue was that the runtime layer must include libociicus.so, otherwise OCI8 fails with:
OCIEnvNlsCreate() failed
Once that library was added to the layer, everything worked as expected.
This setup also works correctly with Laravel using the yajra/laravel-oci8 package, so applications using that driver can run without problems on Lambda.
So yes — this solution has been tested in a real Lambda environment and works correctly with:
• Bref 3
• Amazon Linux 2023
• PHP 8.3+ (8.3 / 8.4 / 8.5)
• Oracle Instant Client 21.12
Update the OCI8 layer for version 3. A lot of this is thanks to the work of @alraben and the previous maintainer's version. It is currently only compatible with PHP 8.3+.
It has been tested against a live app using
arn:aws:lambda:us-west-2:873528684822:layer:php-84:16as the base layer. Hopefully there aren't any sneaky dependency issues that I missed.