Skip to content

Commit 7c85696

Browse files
dnl4Nyholm
andauthored
Added SNMP Support (#469)
* Added SNMP * Update Readme.md * Update layers.json * Update layers.json * Revert "Update layers.json" This reverts commit a8c8b51. * Revert "Update layers.json" This reverts commit c795eaa. * Update layers.json * Apply suggestions from code review --------- Co-authored-by: Tobias Nyholm <[email protected]>
1 parent 81de8bb commit 7c85696

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

Readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ functions:
8686
| Relay | `${bref-extra:relay-php-81}` |
8787
| Scout APM | `${bref-extra:scoutapm-php-81}` |
8888
| Scrypt | `${bref-extra:scrypt-php-81}` |
89+
| SNMP | `${bref-extra:snmp-php-81}` |
8990
| SPX | `${bref-extra:spx-php-81}` |
9091
| SSH2 | `${bref-extra:ssh2-php-81}` |
9192
| Swoole | `${bref-extra:swoole-php-81}` |

layers/snmp/Dockerfile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ARG PHP_VERSION
2+
ARG BREF_VERSION
3+
FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext
4+
5+
RUN LD_LIBRARY_PATH=/lib:/lib64 yum -y install amazon-linux-extras
6+
RUN LD_LIBRARY_PATH=/lib:/lib64 amazon-linux-extras install epel -y
7+
RUN LD_LIBRARY_PATH=/lib:/lib64 yum -y update
8+
RUN LD_LIBRARY_PATH=/lib:/lib64 yum -y install net-snmp net-snmp-{devel,utils}
9+
10+
WORKDIR ${PHP_BUILD_DIR}/ext/snmp
11+
RUN phpize
12+
RUN ./configure --with-libdir=lib64 --disable-static --with-sn
13+
RUN make -j `nproc` && make install
14+
15+
RUN cp `php-config --extension-dir`/snmp.so /tmp/snmp.so
16+
RUN echo 'extension=snmp.so' > /tmp/ext.ini
17+
18+
RUN php /bref/lib-copy/copy-dependencies.php /tmp/snmp.so /tmp/extension-libs
19+
20+
# Build the final image with just the files we need
21+
FROM scratch
22+
23+
# Copy things we installed to the final image
24+
COPY --from=ext /tmp/snmp.so /opt/bref/extensions/snmp.so
25+
COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/ext-snmp.ini
26+
COPY --from=ext /tmp/extension-libs /opt/lib

layers/snmp/config.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"php": [
3+
"81",
4+
"82"
5+
]
6+
}

layers/snmp/test.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
if (!function_exists($func = 'snmp2_real_walk')) {
4+
echo sprintf('FAIL: Function "%s" does not exist.', $func).PHP_EOL;
5+
exit(1);
6+
}
7+
8+
exit(0);

0 commit comments

Comments
 (0)