diff --git a/Dockerfile b/Dockerfile index 9c2b3a214..4fcb83b51 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,18 +12,26 @@ RUN composer update --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM php:7.4-cli as step1 +FROM php:7.4-cli-alpine as step1 ENV TZ=Asia/Tel_Aviv \ - DEBIAN_FRONTEND=noninteractive \ PHP_REDIS_VERSION=5.3.0 \ PHP_SWOOLE_VERSION=4.5.2 \ PHP_XDEBUG_VERSION=sdebug_2_9-beta RUN \ - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests ca-certificates software-properties-common wget git openssl make zip unzip libbrotli-dev libz-dev - + apk add --no-cache --virtual .deps \ + make \ + automake \ + autoconf \ + gcc \ + g++ \ + tar \ + wget \ + git \ + zlib-dev \ + brotli-dev + RUN docker-php-ext-install sockets RUN \ @@ -43,31 +51,14 @@ RUN \ ./configure --enable-sockets --enable-http2 && \ make && make install && \ cd .. - ## XDebug Extension - # git clone https://github.com/swoole/sdebug.git && \ - # cd sdebug && \ - # git checkout $PHP_XDEBUG_VERSION && \ - # phpize && \ - # ./configure --enable-xdebug && \ - # make clean && make && make install - # cd .. && \ - # Meminfo Extension - # git clone https://github.com/BitOne/php-meminfo.git && \ - # cd php-meminfo && \ - # git checkout v1.0.5 && \ - # cd extension/php7 && \ - # phpize && \ - # ./configure --enable-meminfo && \ - # make && make install -FROM php:7.4-cli as final +FROM php:7.4-cli-alpine as final LABEL maintainer="team@appwrite.io" ARG VERSION=dev ENV TZ=Asia/Tel_Aviv \ - DEBIAN_FRONTEND=noninteractive \ _APP_SERVER=swoole \ _APP_ENV=production \ _APP_DOMAIN=localhost \ @@ -103,21 +94,31 @@ ENV TZ=Asia/Tel_Aviv \ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN \ - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests webp certbot htop procps docker.io \ - libonig-dev libcurl4-gnutls-dev libmagickwand-dev libyaml-dev libbrotli-dev libz-dev && \ - pecl install imagick yaml && \ - docker-php-ext-enable imagick yaml - -RUN docker-php-ext-install sockets curl opcache pdo pdo_mysql + apk update \ + && apk add --no-cache --virtual .deps \ + make \ + automake \ + autoconf \ + gcc \ + g++ \ + curl-dev \ + && apk add --no-cache \ + libstdc++ \ + yaml-dev \ + imagemagick \ + imagemagick-dev \ + certbot \ + docker-cli \ + && pecl install imagick yaml \ + && docker-php-ext-enable imagick yaml \ + && docker-php-ext-install sockets opcache pdo_mysql \ + && apk del .deps WORKDIR /usr/src/code COPY --from=step0 /usr/local/src/vendor /usr/src/code/vendor COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ -# COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ -# COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/meminfo.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ # Add Source Code COPY ./app /usr/src/code/app @@ -141,18 +142,18 @@ RUN mkdir -p /storage/uploads && \ chown -Rf www-data.www-data /storage/debug && chmod -Rf 0755 /storage/debug # Executables -RUN chmod +x /usr/local/bin/doctor -RUN chmod +x /usr/local/bin/migrate -RUN chmod +x /usr/local/bin/schedule -RUN chmod +x /usr/local/bin/test -RUN chmod +x /usr/local/bin/worker-audits -RUN chmod +x /usr/local/bin/worker-certificates -RUN chmod +x /usr/local/bin/worker-deletes -RUN chmod +x /usr/local/bin/worker-functions -RUN chmod +x /usr/local/bin/worker-mails -RUN chmod +x /usr/local/bin/worker-tasks -RUN chmod +x /usr/local/bin/worker-usage -RUN chmod +x /usr/local/bin/worker-webhooks +RUN chmod +x /usr/local/bin/doctor && \ + chmod +x /usr/local/bin/migrate && \ + chmod +x /usr/local/bin/schedule && \ + chmod +x /usr/local/bin/test && \ + chmod +x /usr/local/bin/worker-audits && \ + chmod +x /usr/local/bin/worker-certificates && \ + chmod +x /usr/local/bin/worker-deletes && \ + chmod +x /usr/local/bin/worker-functions && \ + chmod +x /usr/local/bin/worker-mails && \ + chmod +x /usr/local/bin/worker-tasks && \ + chmod +x /usr/local/bin/worker-usage && \ + chmod +x /usr/local/bin/worker-webhooks # Letsencrypt Permissions RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/ @@ -160,21 +161,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=redis.so >> /usr/local/etc/php/conf.d/redis.ini -# RUN echo zend_extension=xdebug.so >> /usr/local/etc/php/conf.d/xdebug.ini -# RUN echo extension=meminfo.so >> /usr/local/etc/php/conf.d/meminfo.ini RUN echo "opcache.preload_user=www-data" >> /usr/local/etc/php/conf.d/appwrite.ini RUN echo "opcache.preload=/usr/src/code/app/preload.php" >> /usr/local/etc/php/conf.d/appwrite.ini RUN echo "opcache.enable_cli = 1" >> /usr/local/etc/php/conf.d/appwrite.ini -# RUN echo "xdebug.profiler_enable = 1" >> /usr/local/etc/php/conf.d/appwrite.ini -# RUN echo "xdebug.profiler_output_dir = /tmp/" >> /usr/local/etc/php/conf.d/appwrite.ini -# RUN echo "xdebug.profiler_enable_trigger = 1" >> /usr/local/etc/php/conf.d/appwrite.ini -# RUN echo "xdebug.trace_format = 1" >> /usr/local/etc/php/conf.d/appwrite.ini EXPOSE 80 -#, "-dxdebug.auto_trace=1" -#, "-dxdebug.profiler_enable=1" -#, "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" - CMD [ "php", "app/server.php", "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" ] diff --git a/Dockerfile.swoole b/Dockerfile.debian similarity index 98% rename from Dockerfile.swoole rename to Dockerfile.debian index a2573e0fc..0d55f0a6f 100755 --- a/Dockerfile.swoole +++ b/Dockerfile.debian @@ -92,6 +92,8 @@ ENV TZ=Asia/Tel_Aviv \ _APP_STATSD_PORT=8125 \ _APP_SMTP_HOST=smtp \ _APP_SMTP_PORT=25 \ + _APP_FUNCTIONS_TIMEOUT=900 \ + _APP_FUNCTIONS_CONTAINERS=10 \ _APP_SETUP=self-hosted \ _APP_VERSION=$VERSION #ENV _APP_SMTP_SECURE '' @@ -175,4 +177,4 @@ EXPOSE 80 #, "-dxdebug.profiler_enable=1" #, "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" -CMD [ "php", "app/server.php", "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" ] +CMD [ "php", "app/server.php", "-dopcache.preload=opcache.preload=/usr/src/code/app/preload.php" ] \ No newline at end of file diff --git a/bin/doctor b/bin/doctor index 0fe5965da..022a4d8a5 100755 --- a/bin/doctor +++ b/bin/doctor @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh php /usr/src/code/app/tasks/init.php doctor \ No newline at end of file diff --git a/bin/migrate b/bin/migrate index e6de4a193..509512fae 100755 --- a/bin/migrate +++ b/bin/migrate @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh php /usr/src/code/app/tasks/migrate.php run \ No newline at end of file diff --git a/bin/schedule b/bin/schedule index a9b05916f..74da3fe1e 100644 --- a/bin/schedule +++ b/bin/schedule @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" RESQUE_PHP='/usr/src/code/vendor/autoload.php' php /usr/src/code/vendor/bin/resque-scheduler \ No newline at end of file diff --git a/bin/start b/bin/start index bde1101b4..7dd4ecddc 100755 --- a/bin/start +++ b/bin/start @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh export PHP_VERSION=$PHP_VERSION diff --git a/bin/test b/bin/test index 1f0296c9a..61f606b15 100755 --- a/bin/test +++ b/bin/test @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh /usr/src/code/vendor/bin/phpunit --configuration /usr/src/code/phpunit.xml \ No newline at end of file diff --git a/bin/worker-audits b/bin/worker-audits index 3befdbc04..99b3eac2e 100644 --- a/bin/worker-audits +++ b/bin/worker-audits @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh QUEUE='v1-audits' APP_INCLUDE='/usr/src/code/app/workers/audits.php' REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-certificates b/bin/worker-certificates index f2a1bde94..6d360aff3 100644 --- a/bin/worker-certificates +++ b/bin/worker-certificates @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh QUEUE='v1-certificates' APP_INCLUDE='/usr/src/code/app/workers/certificates.php' REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-deletes b/bin/worker-deletes index 6c623bfd4..d053381db 100644 --- a/bin/worker-deletes +++ b/bin/worker-deletes @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh QUEUE='v1-deletes' APP_INCLUDE='/usr/src/code/app/workers/deletes.php' REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-functions b/bin/worker-functions index 55290c992..787addab0 100644 --- a/bin/worker-functions +++ b/bin/worker-functions @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh QUEUE='v1-functions' APP_INCLUDE='/usr/src/code/app/workers/functions.php' REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-mails b/bin/worker-mails index 7c6ae5f91..8a1a9de97 100644 --- a/bin/worker-mails +++ b/bin/worker-mails @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh QUEUE='v1-mails' APP_INCLUDE='/usr/src/code/app/workers/mails.php' REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-tasks b/bin/worker-tasks index 1474dd286..236b34cb7 100644 --- a/bin/worker-tasks +++ b/bin/worker-tasks @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh QUEUE='v1-tasks' APP_INCLUDE='/usr/src/code/app/workers/tasks.php' REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-usage b/bin/worker-usage index c570eeed7..2b967f8f0 100644 --- a/bin/worker-usage +++ b/bin/worker-usage @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh QUEUE='v1-usage' APP_INCLUDE='/usr/src/code/app/workers/usage.php' REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file diff --git a/bin/worker-webhooks b/bin/worker-webhooks index 9686961a9..d09a4a39a 100644 --- a/bin/worker-webhooks +++ b/bin/worker-webhooks @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh QUEUE='v1-webhooks' APP_INCLUDE='/usr/src/code/app/workers/webhooks.php' REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" php /usr/src/code/vendor/bin/resque -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php \ No newline at end of file