From d5cd136c6b20edae8688a789917f1315f93303c2 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 13 Jun 2020 08:18:07 +0300 Subject: [PATCH 1/5] Build Nginx from source --- Dockerfile | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index efd1344c5..fb8739e40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ENV TZ=Asia/Tel_Aviv \ RUN \ apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests ca-certificates software-properties-common wget curl git openssl && \ + apt-get install -y --no-install-recommends --no-install-suggests ca-certificates software-properties-common wget git openssl && \ LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \ apt-get update && \ apt-get install -y --no-install-recommends --no-install-suggests make php$PHP_VERSION php$PHP_VERSION-dev zip unzip php$PHP_VERSION-zip && \ @@ -23,7 +23,9 @@ RUN \ ./configure && \ make && \ # Composer - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer + wget https://getcomposer.org/composer.phar && \ + chmod +x ./composer.phar && \ + mv ./composer.phar /usr/bin/composer WORKDIR /usr/local/src/ @@ -80,25 +82,44 @@ 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 wget curl ca-certificates software-properties-common openssl gnupg && \ + apt-get install -y --no-install-recommends --no-install-suggests wget ca-certificates software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev htop supervisor openssl gnupg && \ LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \ add-apt-repository universe && \ add-apt-repository ppa:certbot/certbot && \ apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests htop supervisor php$PHP_VERSION php$PHP_VERSION-fpm \ + apt-get install -y --no-install-recommends --no-install-suggests php$PHP_VERSION php$PHP_VERSION-fpm \ php$PHP_VERSION-mysqlnd php$PHP_VERSION-curl php$PHP_VERSION-imagick php$PHP_VERSION-mbstring php$PHP_VERSION-dom webp certbot && \ # Nginx - echo "deb http://nginx.org/packages/mainline/ubuntu/ bionic nginx" >> /etc/apt/sources.list.d/nginx.list && \ - wget -q http://nginx.org/keys/nginx_signing.key && \ - apt-key add nginx_signing.key && \ - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests nginx && \ + # echo "deb http://nginx.org/packages/nginx-1.19.0/ubuntu/ bionic nginx" >> /etc/apt/sources.list.d/nginx.list && \ + # wget -q http://nginx.org/keys/nginx_signing.key && \ + # apt-key add nginx_signing.key && \ + # apt-get update && \ + # apt-get install -y --no-install-recommends --no-install-suggests nginx && \ + wget http://nginx.org/download/nginx-1.19.0.tar.gz && \ + tar -xzvf nginx-1.19.0.tar.gz && rm nginx-1.19.0.tar.gz && \ + cd nginx-1.19.0 && \ + ./configure --prefix=/usr/share/nginx \ + --sbin-path=/usr/sbin/nginx \ + --modules-path=/usr/lib/nginx/modules \ + --conf-path=/etc/nginx/nginx.conf \ + --error-log-path=/var/log/nginx/error.log \ + --http-log-path=/var/log/nginx/access.log \ + --pid-path=/run/nginx.pid \ + --lock-path=/var/lock/nginx.lock \ + --user=www-data \ + --group=www-data \ + --build=Ubuntu \ + --with-http_gzip_static_module \ + --with-http_ssl_module \ + --with-http_v2_module && \ + make && \ + make install && \ # Redis Extension echo extension=redis.so >> /etc/php/$PHP_VERSION/fpm/conf.d/redis.ini && \ echo extension=redis.so >> /etc/php/$PHP_VERSION/cli/conf.d/redis.ini && \ # Cleanup cd ../ && \ - apt-get purge -y --auto-remove software-properties-common gnupg curl && \ + apt-get purge -y --auto-remove software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev gnupg && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* From 2dbba826307efe99dc69065a62f348ae41dde013 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 13 Jun 2020 10:35:29 +0300 Subject: [PATCH 2/5] Added brotli modules --- Dockerfile | 17 ++++++++++------- docker/nginx.conf | 10 ++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index fb8739e40..1a7f8af26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,11 @@ RUN \ # Composer wget https://getcomposer.org/composer.phar && \ chmod +x ./composer.phar && \ - mv ./composer.phar /usr/bin/composer + mv ./composer.phar /usr/bin/composer && \ + #Brotli + cd / && \ + git clone https://github.com/eustas/ngx_brotli.git && \ + cd ngx_brotli && git submodule update --init && cd .. WORKDIR /usr/local/src/ @@ -77,6 +81,8 @@ ENV TZ=Asia/Tel_Aviv \ #ENV _APP_SMTP_PASSWORD '' COPY --from=builder /phpredis-5.2.1/modules/redis.so /usr/lib/php/20190902/ +COPY --from=builder /phpredis-5.2.1/modules/redis.so /usr/lib/php/20190902/ +COPY --from=builder /ngx_brotli /ngx_brotli RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone @@ -90,11 +96,6 @@ RUN \ apt-get install -y --no-install-recommends --no-install-suggests php$PHP_VERSION php$PHP_VERSION-fpm \ php$PHP_VERSION-mysqlnd php$PHP_VERSION-curl php$PHP_VERSION-imagick php$PHP_VERSION-mbstring php$PHP_VERSION-dom webp certbot && \ # Nginx - # echo "deb http://nginx.org/packages/nginx-1.19.0/ubuntu/ bionic nginx" >> /etc/apt/sources.list.d/nginx.list && \ - # wget -q http://nginx.org/keys/nginx_signing.key && \ - # apt-key add nginx_signing.key && \ - # apt-get update && \ - # apt-get install -y --no-install-recommends --no-install-suggests nginx && \ wget http://nginx.org/download/nginx-1.19.0.tar.gz && \ tar -xzvf nginx-1.19.0.tar.gz && rm nginx-1.19.0.tar.gz && \ cd nginx-1.19.0 && \ @@ -111,7 +112,8 @@ RUN \ --build=Ubuntu \ --with-http_gzip_static_module \ --with-http_ssl_module \ - --with-http_v2_module && \ + --with-http_v2_module \ + --add-module=/ngx_brotli && \ make && \ make install && \ # Redis Extension @@ -121,6 +123,7 @@ RUN \ cd ../ && \ apt-get purge -y --auto-remove software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev gnupg && \ apt-get clean && \ + rm -rf /ngx_brotli && \ rm -rf /var/lib/apt/lists/* # Set Upload Limit (default to 100MB) diff --git a/docker/nginx.conf b/docker/nginx.conf index b1a569029..7b62ec9a5 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -46,6 +46,16 @@ http { gzip_http_version 1.1; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml; + # Brotli Settings + brotli on; + brotli_comp_level 5; + brotli_static on; + brotli_types application/atom+xml application/javascript application/json application/rss+xml + application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype + application/x-font-ttf application/x-javascript application/xhtml+xml application/xml + font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon + image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml; + # Virtual Host Configs server { listen 80; ## listen for ipv4; this line is default and implied From 539346317c4878393283a8bfcd409c01734d23ff Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 13 Jun 2020 11:26:27 +0300 Subject: [PATCH 3/5] Image optimization --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1a7f8af26..d3dba9345 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,7 +88,7 @@ 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 wget ca-certificates software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev htop supervisor openssl gnupg && \ + apt-get install -y --no-install-recommends --no-install-suggests wget ca-certificates software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev openssl gnupg htop supervisor && \ LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \ add-apt-repository universe && \ add-apt-repository ppa:certbot/certbot && \ @@ -116,12 +116,13 @@ RUN \ --add-module=/ngx_brotli && \ make && \ make install && \ + rm -rf ../nginx-1.19.0 && \ # Redis Extension echo extension=redis.so >> /etc/php/$PHP_VERSION/fpm/conf.d/redis.ini && \ echo extension=redis.so >> /etc/php/$PHP_VERSION/cli/conf.d/redis.ini && \ # Cleanup cd ../ && \ - apt-get purge -y --auto-remove software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev gnupg && \ + apt-get purge -y --auto-remove wget ca-certificates software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev gnupg && \ apt-get clean && \ rm -rf /ngx_brotli && \ rm -rf /var/lib/apt/lists/* From bd12352d608bd1ae549e542331b7e7f06b3d22ed Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 13 Jun 2020 11:28:36 +0300 Subject: [PATCH 4/5] Updated change log --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 2ba4e152e..670d33dd7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ - Added option to delete team from the console - Added option to view team members from the console - Added option to join a user to any team from the console +- Added support for Brotli compression ## Bug Fixes From 67f9ceb2316f4ce57355bd70dce308eee9d45d1c Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 13 Jun 2020 11:48:28 +0300 Subject: [PATCH 5/5] Fixed tests --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d3dba9345..1f41c3e33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -122,7 +122,7 @@ RUN \ echo extension=redis.so >> /etc/php/$PHP_VERSION/cli/conf.d/redis.ini && \ # Cleanup cd ../ && \ - apt-get purge -y --auto-remove wget ca-certificates software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev gnupg && \ + apt-get purge -y --auto-remove wget software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev gnupg && \ apt-get clean && \ rm -rf /ngx_brotli && \ rm -rf /var/lib/apt/lists/*