Skip to content

Commit da2b8ab

Browse files
authored
Merge pull request #567 from semsphy/master
Added h3 extension layer
2 parents 492e2a2 + 3a8cca8 commit da2b8ab

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ a limit of 5 layers per Lambda. You can also utilise the provided docker images
1414
1515

1616
> **Warning**
17-
>
17+
>
1818
> **ARM64 is not supported yet with Bref v2.**
1919
2020

@@ -64,6 +64,7 @@ functions:
6464
| gnupg | `${bref-extra:gnupg-php-81}` |
6565
| GMP | `${bref-extra:gmp-php-81}` |
6666
| gRPC | `${bref-extra:grpc-php-81}` |
67+
| h3 | `${bref-extra:h3-php-81}` |
6768
| Igbinary | `${bref-extra:igbinary-php-81}` |
6869
| Imagick | `${bref-extra:imagick-php-81}` |
6970
| IMAP | `${bref-extra:imap-php-81}` |

layers/h3/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
ARG PHP_VERSION
2+
ARG BREF_VERSION
3+
FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext
4+
ARG PHP_VERSION
5+
6+
# Prepare environment
7+
ENV H3_BUILD_DIR=${BUILD_DIR}/h3
8+
RUN mkdir -p ${H3_BUILD_DIR}
9+
10+
# Compile h3
11+
WORKDIR ${H3_BUILD_DIR}
12+
RUN git clone https://github.com/uber/h3.git && \
13+
cd h3 && \
14+
git checkout v3.7.2 && \
15+
cmake -DBUILD_SHARED_LIBS=ON . && \
16+
make -j "$(nproc)" && \
17+
make install
18+
19+
# Compile the php h3 extension
20+
WORKDIR ${H3_BUILD_DIR}/h3-php
21+
RUN curl -L https://github.com/abler98/h3-php/archive/refs/tags/v1.0.0.tar.gz -o h3.tar.gz && \
22+
tar xzf h3.tar.gz && \
23+
cd h3-php-1.0.0 && \
24+
phpize && \
25+
./configure --with-h3 && \
26+
make && \
27+
make install
28+
29+
RUN cp `php-config --extension-dir`/h3.so /tmp/h3.so
30+
RUN strip --strip-debug /tmp/h3.so
31+
RUN echo 'extension=h3.so' > /tmp/ext.ini
32+
33+
RUN php /bref/lib-copy/copy-dependencies.php /tmp/h3.so /tmp/extension-libs
34+
35+
# Build the final image with just the files we need
36+
FROM scratch
37+
38+
# Copy things we installed to the final image
39+
COPY --from=ext /tmp/h3.so /opt/bref/extensions/h3.so
40+
COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/ext-h3.ini
41+
COPY --from=ext /tmp/extension-libs /opt/lib

layers/h3/config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"php": [
3+
"80",
4+
"81",
5+
"82",
6+
"83"
7+
]
8+
}

layers/h3/test.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
if (!class_exists($class = \H3\H3Index::class)) {
4+
echo sprintf('FAIL: Class "%s" does not exist.', $class).PHP_EOL;
5+
exit(1);
6+
}
7+
8+
9+
exit(0);

0 commit comments

Comments
 (0)