diff --git a/Dockerfile b/Dockerfile index 3bfe6decb..403f247e3 100755 --- a/Dockerfile +++ b/Dockerfile @@ -33,8 +33,6 @@ ENV PHP_REDIS_VERSION=5.3.7 \ PHP_MONGODB_VERSION=1.13.0 \ PHP_SWOOLE_VERSION=v4.8.9 \ PHP_IMAGICK_VERSION=3.7.0 \ - # For SCRYPT never go v1.4.2 or lower. That doesnt work on PHP 8 + Alpine3.15/16 - PHP_SCRYPT_COMMIT_SHA=3b01fd422300032d2ba91f978d8c9131fa519b72 \ PHP_YAML_VERSION=2.2.2 \ PHP_MAXMINDDB_VERSION=v1.11.0 @@ -96,16 +94,6 @@ RUN \ ./configure && \ make && make install -## Scrypt Extension -FROM compile AS scrypt -RUN \ - git clone --depth 1 --branch master https://github.com/DomBlack/php-scrypt.git && \ - cd php-scrypt && \ - git reset --hard $PHP_SCRYPT_COMMIT_SHA && \ - phpize && \ - ./configure --enable-scrypt && \ - make && make install - ## YAML Extension FROM compile AS yaml RUN \ @@ -135,6 +123,33 @@ RUN \ ./configure && \ make && make install +# Rust Extensions Compile Image +FROM php:8.0.18-cli as rust_compile + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + +ENV PATH=/root/.cargo/bin:$PATH + +RUN apt-get update && apt-get install musl-tools build-essential libclang-dev clang-11 git tree -y +RUN rustup target add $(uname -m)-unknown-linux-musl + +# Install ZigBuild for easier cross-compilation +RUN curl https://ziglang.org/builds/zig-linux-$(uname -m)-0.10.0-dev.2674+d980c6a38.tar.xz --output /tmp/zig.tar.xz +RUN tar -xf /tmp/zig.tar.xz -C /tmp/ && cp -r /tmp/zig-linux-x86_64-0.10.0-dev.2674+d980c6a38 /tmp/zig/ +ENV PATH=/tmp/zig:$PATH +RUN cargo install cargo-zigbuild +ENV RUSTFLAGS="-C target-feature=-crt-static" + +FROM rust_compile as scrypt + +WORKDIR /usr/local/lib/php/extensions/ + +RUN \ + git clone --depth 1 https://github.com/PineappleIOnic/scrypt-php.git && \ + cd scrypt-php && \ + cargo zigbuild --workspace --all-targets --target $(uname -m)-unknown-linux-musl --release && \ + mv target/$(uname -m)-unknown-linux-musl/release/libscrypt_php.so target/libscrypt_php.so + FROM php:8.0.18-cli-alpine3.15 as final LABEL maintainer="team@appwrite.io" @@ -251,6 +266,7 @@ RUN \ libmaxminddb-dev \ certbot \ docker-cli \ + docker-compose \ libgomp \ && docker-php-ext-install sockets opcache pdo_mysql \ && apk del .deps \ @@ -277,7 +293,7 @@ COPY --from=imagick /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imag COPY --from=yaml /usr/local/lib/php/extensions/no-debug-non-zts-20200930/yaml.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ COPY --from=maxmind /usr/local/lib/php/extensions/no-debug-non-zts-20200930/maxminddb.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ COPY --from=mongodb /usr/local/lib/php/extensions/no-debug-non-zts-20200930/mongodb.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ -COPY --from=scrypt /usr/local/lib/php/extensions/no-debug-non-zts-20200930/scrypt.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ +COPY --from=scrypt /usr/local/lib/php/extensions/scrypt-php/target/libscrypt_php.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ # Add Source Code COPY ./app /usr/src/code/app @@ -330,11 +346,11 @@ RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/ # Enable Extensions RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini -RUN echo extension=scrypt.so >> /usr/local/etc/php/conf.d/scrypt.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=libscrypt_php.so >> /usr/local/etc/php/conf.d/libscrypt_php.ini RUN if [ "$DEBUG" == "true" ]; then printf "zend_extension=yasd \nyasd.debug_mode=remote \nyasd.init_file=/usr/local/dev/yasd_init.php \nyasd.remote_port=9005 \nyasd.log_level=-1" >> /usr/local/etc/php/conf.d/yasd.ini; fi RUN if [ "$DEBUG" == "true" ]; then echo "opcache.enable=0" >> /usr/local/etc/php/conf.d/appwrite.ini; fi