Skip to content

Commit

Permalink
Added h3 extension layer
Browse files Browse the repository at this point in the history
  • Loading branch information
semsphy committed Nov 18, 2024
1 parent 2992310 commit cb6c3d0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ functions:
| gnupg | `${bref-extra:gnupg-php-81}` |
| GMP | `${bref-extra:gmp-php-81}` |
| gRPC | `${bref-extra:grpc-php-81}` |
| h3 | `${bref-extra:grpc-php-81}` |
| Igbinary | `${bref-extra:igbinary-php-81}` |
| Imagick | `${bref-extra:imagick-php-81}` |
| IMAP | `${bref-extra:imap-php-81}` |
Expand Down
41 changes: 41 additions & 0 deletions layers/h3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ARG PHP_VERSION
ARG BREF_VERSION
FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext
ARG PHP_VERSION

# Prepare environment
ENV H3_BUILD_DIR=${BUILD_DIR}/h3
RUN mkdir -p ${H3_BUILD_DIR}

# Compile h3
WORKDIR ${H3_BUILD_DIR}
RUN git clone https://github.com/uber/h3.git && \
cd h3 && \
git checkout v3.7.2 && \
cmake -DBUILD_SHARED_LIBS=ON . && \
make -j "$(nproc)" && \
make install

# Compile the php h3 extension
WORKDIR ${H3_BUILD_DIR}/h3-php
RUN curl -L https://github.com/abler98/h3-php/archive/refs/tags/v1.0.0.tar.gz -o h3.tar.gz && \
tar xzf h3.tar.gz && \
cd h3-php-1.0.0 && \
phpize && \
./configure --with-h3 && \
make && \
make install

RUN cp `php-config --extension-dir`/h3.so /tmp/h3.so
RUN strip --strip-debug /tmp/h3.so
RUN echo 'extension=h3.so' > /tmp/ext.ini

RUN php /bref/lib-copy/copy-dependencies.php /tmp/h3.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/h3.so /opt/bref/extensions/h3.so
COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/ext-h3.ini
COPY --from=ext /tmp/extension-libs /opt/lib
8 changes: 8 additions & 0 deletions layers/h3/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"php": [
"80",
"81",
"82",
"83"
]
}
9 changes: 9 additions & 0 deletions layers/h3/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

if (!class_exists($class = \H3\H3Index::class)) {
echo sprintf('FAIL: Class "%s" does not exist.', $class).PHP_EOL;
exit(1);
}


exit(0);

0 comments on commit cb6c3d0

Please sign in to comment.