Skip to content

Commit

Permalink
Create a layer for the opentelemetrt php extension
Browse files Browse the repository at this point in the history
  • Loading branch information
iokiwi committed Nov 19, 2023
1 parent 5ee7ec3 commit 621e4b1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions layers/opentelemetry/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://github.com/brefphp/extra-php-extensions/blob/master/layers/yaml/Dockerfile

ARG PHP_VERSION
ARG BREF_VERSION
FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext

RUN MAKEFLAGS="-j $(nproc)" && pecl install opentelemetry > /dev/null
RUN cp `php-config --extension-dir`/opentelemetry.so /tmp/opentelemetry.so
RUN strip --strip-debug /tmp/opentelemetry.so
RUN echo 'extension=opentelemetry.so' > /tmp/ext.ini

# Build the final image with just the files we need
FROM scratch

# Copy things we installed to the final image
COPY --from=ext /tmp/opentelemetry.so /opt/bref/extensions/opentelemetry.so
COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/ext-opentelemetry.ini
7 changes: 7 additions & 0 deletions layers/opentelemetry/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"php": [
"80",
"81",
"82"
]
}
8 changes: 8 additions & 0 deletions layers/opentelemetry/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

if (!function_exists($function = "OpenTelemetry\Instrumentation\hook")) {
echo sprintf('FAIL: Function "%s" does not exist.', $function).PHP_EOL;
exit(1);
}

exit(0);

0 comments on commit 621e4b1

Please sign in to comment.