Skip to content

Commit

Permalink
Merge pull request #36 from appwrite/extensions
Browse files Browse the repository at this point in the history
feat: cloud extensions
  • Loading branch information
basert authored Nov 19, 2024
2 parents 91575f9 + 08ae789 commit 7da7be2
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 125 deletions.
31 changes: 20 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ ENV PHP_REDIS_VERSION="6.1.0" \
PHP_BROTLI_VERSION="0.15.0" \
PHP_SNAPPY_VERSION="c27f830dcfe6c41eb2619a374de10fd0597f4939" \
PHP_LZ4_VERSION="2f006c3e4f1fb3a60d2656fc164f9ba26b71e995" \
PHP_XDEBUG_VERSION="3.3.2"
PHP_XDEBUG_VERSION="3.3.2" \
PHP_OPENTELEMETRY_VERSION="1.1.0" \
PHP_PROTOBUF_VERSION="4.28.3"

RUN \
apk add --no-cache --virtual .deps \
Expand All @@ -31,6 +33,8 @@ RUN \
imagemagick-dev \
libjpeg-turbo-dev \
jpeg-dev \
zlib-dev \
libpng-dev \
libjxl-dev \
libmaxminddb-dev \
zstd-dev \
Expand Down Expand Up @@ -151,6 +155,15 @@ RUN \
./configure && \
make && make install

FROM compile AS opentelemetry
RUN pecl install opentelemetry-${PHP_OPENTELEMETRY_VERSION}

FROM compile AS protobuf
RUN pecl install protobuf-${PHP_PROTOBUF_VERSION}

FROM compile AS gd
RUN docker-php-ext-install gd

FROM $BASEIMAGE as final

LABEL maintainer="[email protected]"
Expand Down Expand Up @@ -188,6 +201,8 @@ RUN \
libavif \
libheif \
imagemagick-heic \
zlib-dev \
libpng-dev \
libmaxminddb-dev \
certbot \
docker-cli \
Expand Down Expand Up @@ -217,18 +232,12 @@ COPY --from=brotli /usr/local/lib/php/extensions/no-debug-non-zts-20230831/brotl
COPY --from=lz4 /usr/local/lib/php/extensions/no-debug-non-zts-20230831/lz4.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/
COPY --from=snappy /usr/local/lib/php/extensions/no-debug-non-zts-20230831/snappy.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/
COPY --from=xdebug /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/
COPY --from=opentelemetry /usr/local/lib/php/extensions/no-debug-non-zts-20230831/opentelemetry.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/
COPY --from=protobuf /usr/local/lib/php/extensions/no-debug-non-zts-20230831/protobuf.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/
COPY --from=gd /usr/local/lib/php/extensions/no-debug-non-zts-20230831/gd.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/

# Enable Extensions
RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini
RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini
RUN echo extension=imagick.so >> /usr/local/etc/php/conf.d/imagick.ini
RUN echo extension=yaml.so >> /usr/local/etc/php/conf.d/yaml.ini
RUN echo extension=maxminddb.so >> /usr/local/etc/php/conf.d/maxminddb.ini
RUN echo extension=scrypt.so >> /usr/local/etc/php/conf.d/scrypt.ini
RUN echo extension=zstd.so >> /usr/local/etc/php/conf.d/zstd.ini
RUN echo extension=brotli.so >> /usr/local/etc/php/conf.d/brotli.ini
RUN echo extension=lz4.so >> /usr/local/etc/php/conf.d/lz4.ini
RUN echo extension=snappy.so >> /usr/local/etc/php/conf.d/snappy.ini
RUN docker-php-ext-enable swoole redis imagick yaml maxminddb scrypt zstd brotli lz4 snappy opentelemetry protobuf gd

EXPOSE 80

Expand Down
165 changes: 51 additions & 114 deletions tests.yaml
Original file line number Diff line number Diff line change
@@ -1,104 +1,4 @@
schemaVersion: '2.0.0'

fileExistenceTests:
## Extension files
- name: 'Check swoole extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/swoole.so
shouldExist: true
- name: 'Check redis extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/redis.so
shouldExist: true
- name: 'Check imagick extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/imagick.so
shouldExist: true
- name: 'Check yaml extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/yaml.so
shouldExist: true
- name: 'Check maxminddb extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/maxminddb.so
shouldExist: true
- name: 'Check mongodb extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/mongodb.so
shouldExist: true
- name: 'Check scrypt extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/scrypt.so
shouldExist: true
- name: 'Check zstd extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/zstd.so
shouldExist: true
- name: 'Check brotli extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/brotli.so
shouldExist: true
- name: 'Check lz4 extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/lz4.so
shouldExist: true
- name: 'Check snappy extension'
path: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/snappy.so
shouldExist: true

## ini files
- name: 'Check swoole ini'
path: /usr/local/etc/php/conf.d/swoole.ini
shouldExist: true
- name: 'Check redis ini'
path: /usr/local/etc/php/conf.d/redis.ini
shouldExist: true
- name: 'Check imagick ini'
path: /usr/local/etc/php/conf.d/imagick.ini
shouldExist: true
- name: 'Check yaml ini'
path: /usr/local/etc/php/conf.d/yaml.ini
shouldExist: true
- name: 'Check maxminddb ini'
path: /usr/local/etc/php/conf.d/maxminddb.ini
shouldExist: true
- name: 'Check scrypt ini'
path: /usr/local/etc/php/conf.d/scrypt.ini
shouldExist: true
- name: 'Check zstd ini'
path: /usr/local/etc/php/conf.d/zstd.ini
shouldExist: true
- name: 'Check brotli ini'
path: /usr/local/etc/php/conf.d/brotli.ini
shouldExist: true
- name: 'Check lz4 ini'
path: /usr/local/etc/php/conf.d/lz4.ini
shouldExist: true
- name: 'Check snappy ini'
path: /usr/local/etc/php/conf.d/snappy.ini
shouldExist: true

fileContentTests:
- name: 'swoole ini'
path: '/usr/local/etc/php/conf.d/swoole.ini'
expectedContents: ['extension=swoole.so']
- name: 'redis ini'
path: '/usr/local/etc/php/conf.d/redis.ini'
expectedContents: ['extension=redis.so']
- name: 'imagick ini'
path: '/usr/local/etc/php/conf.d/imagick.ini'
expectedContents: ['extension=imagick.so']
- name: 'yaml ini'
path: '/usr/local/etc/php/conf.d/yaml.ini'
expectedContents: ['extension=yaml.so']
- name: 'maxminddb ini'
path: '/usr/local/etc/php/conf.d/maxminddb.ini'
expectedContents: ['extension=maxminddb.so']
- name: 'scrypt ini'
path: '/usr/local/etc/php/conf.d/scrypt.ini'
expectedContents: ['extension=scrypt.so']
- name: 'zstd ini'
path: '/usr/local/etc/php/conf.d/zstd.ini'
expectedContents: ['extension=zstd.so']
- name: 'brotli ini'
path: '/usr/local/etc/php/conf.d/brotli.ini'
expectedContents: ['extension=brotli.so']
- name: 'lz4 ini'
path: '/usr/local/etc/php/conf.d/lz4.ini'
expectedContents: ['extension=lz4.so']
- name: 'snappy ini'
path: '/usr/local/etc/php/conf.d/snappy.ini'
expectedContents: ['extension=snappy.so']

commandTests:
- name: 'Imagemagick command'
Expand All @@ -121,21 +21,58 @@ commandTests:
command: "php"
args: ["-m"]
expectedOutput:
- ".*imagick.*"
- ".*maxminddb.*"
- ".*swoole.*"
- ".*redis.*"
- ".*yaml.*"
- ".*scrypt.*"
- ".*curl.*"
- ".*PDO.*"
- ".*pdo_mysql.*"
- ".*zstd.*"
- ".*brotli.*"
- ".*lz4.*"
- ".*snappy.*"
- brotli
- Core
- ctype
- curl
- date
- dom
- fileinfo
- filter
- gd
- hash
- iconv
- imagick
- intl
- json
- libxml
- lz4
- maxminddb
- mbstring
- mysqlnd
- openssl
- opentelemetry
- pcre
- PDO
- pdo_mysql
- pdo_pgsql
- pdo_sqlite
- Phar
- posix
- protobuf
- random
- readline
- redis
- Reflection
- scrypt
- session
- SimpleXML
- snappy
- sockets
- sodium
- SPL
- sqlite3
- standard
- swoole
- tokenizer
- xml
- xmlreader
- xmlwriter
- yaml
- zlib
- zstd
- name: 'PHP intl'
command: "php"
args: ["-r", 'print(\Normalizer::FORM_D);']
expectedOutput:
- "4"
- "4"

0 comments on commit 7da7be2

Please sign in to comment.