Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Support Alpine #1181

Open
wernight opened this issue Apr 22, 2016 · 98 comments · Fixed by #1598
Open

Support Alpine #1181

wernight opened this issue Apr 22, 2016 · 98 comments · Fixed by #1598

Comments

@wernight
Copy link
Contributor

wernight commented Apr 22, 2016

The direction is going towards using Docker, and on Docker the direction is towards using Alpine base images (because they're smaller), and most main packages now support Alpine (Nginx included).

It seems that it almost compiles on alpine:edge. I got past the traceback by installing libunwind@testing package but some missing references remain:

psol/lib/Release/linux/x64/pagespeed_automatic.a(1.time.o.o): In function `base::Time::FromDoubleT(dtime.cc:(.text._ZN4base4Time11FromDoubleTEd+0x2a): undefined reference to `__isnan'
psol/lib/Release/linux/x64/pagespeed_automatic.a(96.string_util.o.o): In function `net_instaweb::Str
string_util.cc:(.text._ZN12net_instaweb14StringToDoubleEPKcPd+0x14): undefined reference to `__strtod_internal'
pagespeed_automatic.a(132.ucnv.o.o): In function `pagespeed_ol_ucnv_conveucnv.c:(.text.ucnv_convertEx_46+0x6db): undefined reference to `__rawmemchr'
pagespeed_automatic.a(132.ucnv.o.o): In function `ucnv_internalConvert':
ucnv.c:(.text.ucnv_internalConvert+0x276): undefined reference to `__rawmemchr'
pagespeed_automatic.a(132.uloc.o.o): In function `pagespeed_ol_uloc_accep
uloc.c:(.text.uloc_acceptLanguageFromHTTP_46+0x214): undefined reference to `__strtod_internal'
uloc.c:(.text.uloc_acceptLanguageFromHTTP_46+0x452): undefined reference to `__strtod_internal'
pagespeed_automatic.a(132.uniset_props.o.o): In function `icu_46::Unicode
uniset_props.cpp:(.text._ZN6icu_4610UnicodeSet18applyPropertyAliasERKNS_13UnicodeStringES3_R10UErrorCode+0x35e): undefined reference to `__str
uniset_props.cpp:(.text._ZN6icu_4610UnicodeSet18applyPropertyAliasERKNS_13UnicodeStringES3_R10UErrorCode+0x462): undefined reference to `__str

It's worth finding how to make it compile and document it.

@wernight
Copy link
Contributor Author

Related to #1166

@morlovich
Copy link
Contributor

Just to make sure: are you building psol.a yourself?

@wernight
Copy link
Contributor Author

wernight commented Apr 22, 2016

Yes, I did (following mostly https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source#dependencies):

Dockerfile:

FROM alpine:edge

RUN set -x && \
    echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
    apk add --update ca-certificates curl g++ libunwind@testing && \

    cd /tmp && \
    NPS_VERSION=1.11.33.0 && \
    curl -L https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -o release-${NPS_VERSION}-beta.zip && \
    unzip release-${NPS_VERSION}-beta.zip && \
    cd ngx_pagespeed-release-${NPS_VERSION}-beta/ && \
    curl -L https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz | tar -xzv && \

    cd /tmp && \
    NGINX_VERSION=1.8.1 && \
    curl -L http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar -xvz  && \
    cd nginx-${NGINX_VERSION}/ && \
    ./configure --add-module=/tmp/ngx_pagespeed-release-${NPS_VERSION}-beta

Then looking at objs/autoconf.err for errors.

@morlovich
Copy link
Contributor

curl -L https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
| tar -xzv &&

^^^

This bit is grabbing psol.a as a binary, which is not really workable
with a non-glibc system.

Sadly you near certainly need to hand-build psol.a for your system the
longer and more complicated way:
https://github.com/pagespeed/ngx_pagespeed/wiki/Building-PSOL-From-Source

(That probably expects BRANCH to be set...)

On Fri, Apr 22, 2016 at 4:53 PM, Werner Beroux notifications@github.com
wrote:

Yes, I did (following mostly
https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source#dependencies
):

FROM alpine:edge

RUN set -x &&
echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories &&
apk add --update ca-certificates curl g++ libunwind@testing && \

cd /tmp && \
NPS_VERSION=1.11.33.0 && \
curl -L https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -o release-${NPS_VERSION}-beta.zip && \
unzip release-${NPS_VERSION}-beta.zip && \
cd ngx_pagespeed-release-${NPS_VERSION}-beta/ && \
curl -L https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz | tar -xzv && \

cd /tmp && \
NGINX_VERSION=1.8.1 && \
curl -L http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar -xvz  && \
cd nginx-${NGINX_VERSION}/ && \
./configure --add-module=/tmp/ngx_pagespeed-release-${NPS_VERSION}-beta

Then looking at objs/autoconf.err for errors.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#1181 (comment)

@wernight
Copy link
Contributor Author

Sounds legit. My point is that a documentation for Alpine would be very welcome because it's where I think the near future lives.

Ideally it'd also be package of Alpine.

@cchamplin
Copy link

@wernight Preliminary work to get this created as an Alpine package is available here https://github.com/cchamplin/alpine-ngx-pagespeed. There is still several things that need to happen before I'll start going through the process of submitting to the Alpine repos. Most importantly is that I need it tested on fresh alpine installs.

Ideally we'd also see psol updated at some point to use modern versions of libpng so that we don't have to package an ancient copy of libpng12.

@wernight
Copy link
Contributor Author

To test it, just use docker run --rm -it alpine. You can specify which version of Alpine you want to run as well. That would be very fast. If you don't have Docker, simply run curl -fsSL https://get.docker.com/ | sh and that should be it.

@nikolay
Copy link
Contributor

nikolay commented May 31, 2016

This is super important to have in place! By the way, v3.4.0 is out1

@wernight
Copy link
Contributor Author

wernight commented Jun 1, 2016

Can't you just test on Docker? That should be simple. docker run --rm -it
alpine

Le mar. 31 mai 2016 à 20:56, Nikolay Kolev notifications@github.com a
écrit :

This is super important to have in place! By the way, v3.4.0 is out
http://alpinelinux.org/posts/Alpine-3.4.0-released.html1


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#1181 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAI5A829kZUevIS2oN72eEP6Dhd9nZMdks5qHIRsgaJpZM4IN6ge
.

@wernight
Copy link
Contributor Author

I'm running https://github.com/cchamplin/alpine-ngx-pagespeed on fresh Alpine for some time now without real issues, however it seems to be not maintained.

I see 3 places that would potentially welcome PageSpeed for Nginx on Linux Alpine:

  • PageSpeed itself: Document how to build
  • Linux Alpine: Package
  • Docker Nginx image (quite unlikely)

I agree it'd be easier if we could use a modern libpng.

@wernight
Copy link
Contributor Author

I've a working updated Dockerfile that builds Nginx + PageSpeed if anyone is interested. It's IMO better formatted than wunderkraut/alpine-nginx-pagespeed, very slow to build, but working.

@iler
Copy link

iler commented Sep 30, 2016

@wernight we (Wunderkraut) would like to work together with this task to get a working version out for everyone. We had a pause in our internal development with this but have now continued with this and would like to cooperate with the effort.

cc: @aleksijohansson

@aleksijohansson
Copy link

@wernight Very interested, please share!

@wernight
Copy link
Contributor Author

wernight commented Oct 1, 2016

FROM alpine:3.4

RUN apk --no-cache add \
        ca-certificates \
        libuuid \
        apr \
        apr-util \
        libjpeg-turbo \
        icu \
        icu-libs \
        openssl \
        pcre \
        zlib
RUN set -x && \
    apk --no-cache add -t .build-deps \
        apache2-dev \
        apr-dev \
        apr-util-dev \
        build-base \
        curl \
        icu-dev \
        libjpeg-turbo-dev \
        linux-headers \
        gperf \
        openssl-dev \
        pcre-dev \
        python \
        zlib-dev && \
    # Build libpng:
    # This sadly requires an old version of http://www.libpng.org/pub/png/libpng.html
    LIBPNG_VERSION=1.2.56 && \
    cd /tmp && \
    curl -L http://prdownloads.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz | tar -zx && \
    cd /tmp/libpng-${LIBPNG_VERSION} && \
    ./configure --build=$CBUILD --host=$CHOST --prefix=/usr --enable-shared --with-libpng-compat && \
    make install V=0 && \
    # Build PageSpeed:
    # Check https://github.com/pagespeed/ngx_pagespeed/releases for the latest version
    PAGESPEED_VERSION=1.11.33.3 && \
    cd /tmp && \
    curl -L https://dl.google.com/dl/linux/mod-pagespeed/tar/beta/mod-pagespeed-beta-${PAGESPEED_VERSION}-r0.tar.bz2 | tar -jx && \
    curl -L https://github.com/pagespeed/ngx_pagespeed/archive/v${PAGESPEED_VERSION}-beta.tar.gz | tar -zx && \
    cd /tmp/modpagespeed-${PAGESPEED_VERSION} && \
    curl -L https://raw.githubusercontent.com/iler/alpine-nginx-pagespeed/master/patches/automatic_makefile.patch | patch -p1 && \
    curl -L https://raw.githubusercontent.com/iler/alpine-nginx-pagespeed/master/patches/libpng_cflags.patch | patch -p1 && \
    curl -L https://raw.githubusercontent.com/iler/alpine-nginx-pagespeed/master/patches/pthread_nonrecursive_np.patch | patch -p1 && \
    curl -L https://raw.githubusercontent.com/iler/alpine-nginx-pagespeed/master/patches/rename_c_symbols.patch | patch -p1 && \
    curl -L https://raw.githubusercontent.com/iler/alpine-nginx-pagespeed/master/patches/stack_trace_posix.patch | patch -p1 && \
    ./generate.sh -D use_system_libs=1 -D _GLIBCXX_USE_CXX11_ABI=0 -D use_system_icu=1 && \
    cd /tmp/modpagespeed-${PAGESPEED_VERSION}/src && \
    make BUILDTYPE=Release CXXFLAGS=" -I/usr/include/apr-1 -I/tmp/libpng-${LIBPNG_VERSION} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" CFLAGS=" -I/usr/include/apr-1 -I/tmp/libpng-${LIBPNG_VERSION} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" && \
    cd /tmp/modpagespeed-${PAGESPEED_VERSION}/src/pagespeed/automatic/ && \
    make psol BUILDTYPE=Release CXXFLAGS=" -I/usr/include/apr-1 -I/tmp/libpng-${LIBPNG_VERSION} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" CFLAGS=" -I/usr/include/apr-1 -I/tmp/libpng-${LIBPNG_VERSION} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" && \
    mkdir -p /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol && \
    mkdir -p /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/lib/Release/linux/x64 && \
    mkdir -p /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/out/Release && \
    cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/out/Release/obj /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/out/Release/ && \
    cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/net /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
    cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/testing /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
    cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/pagespeed /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
    cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/third_party /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
    cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/tools /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
    cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/pagespeed/automatic/pagespeed_automatic.a /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/lib/Release/linux/x64 && \
    # Build Nginx with support for PageSpeed:
    # Check http://nginx.org/en/download.html for the latest version.
    NGINX_VERSION=1.10.1 && \
    cd /tmp && \
    curl -L http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar -zx && \
    cd /tmp/nginx-${NGINX_VERSION} && \
    LD_LIBRARY_PATH=/tmp/modpagespeed-${PAGESPEED_VERSION}/usr/lib ./configure --with-ipv6 \
        --prefix=/var/lib/nginx \
        --sbin-path=/usr/sbin \
        --modules-path=/usr/lib/nginx \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --with-file-aio \
        --with-http_v2_module \
        --without-http_autoindex_module \
        --without-http_browser_module \
        --without-http_geo_module \
        --without-http_map_module \
        --without-http_memcached_module \
        --without-http_userid_module \
        --without-mail_pop3_module \
        --without-mail_imap_module \
        --without-mail_smtp_module \
        --without-http_split_clients_module \
        --without-http_scgi_module \
        --without-http_referer_module \
        --without-http_upstream_ip_hash_module \
        --prefix=/etc/nginx \
        --conf-path=/etc/nginx/nginx.conf \
        --http-log-path=/var/log/nginx/access.log \
        --error-log-path=/var/log/nginx/error.log \
        --pid-path=/var/run/nginx.pid \
        --add-module=/tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta \
        --with-cc-opt="-fPIC -I /usr/include/apr-1" \
        --with-ld-opt="-luuid -lapr-1 -laprutil-1 -licudata -licuuc -L/tmp/modpagespeed-${PAGESPEED_VERSION}/usr/lib -lpng12 -lturbojpeg -ljpeg" && \
    make install --silent && \
    # Clean-up:
    cd && \
    apk del .build-deps && \
    rm -rf /tmp/* && \
    # forward request and error logs to docker log collector
    ln -sf /dev/stdout /var/log/nginx/access.log && \
    ln -sf /dev/stderr /var/log/nginx/error.log && \
    # Make PageSpeed cache writabl:
    mkdir -p /var/cache/ngx_pagespeed && \
    chmod -R o+wr /var/cache/ngx_pagespeed

WORKDIR /srv

EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]

@aleksijohansson
Copy link

@wernight Awesome, thanks! Seems to build successfully at least

@ciarans
Copy link

ciarans commented Dec 15, 2016

@wernight's fix was great but now doesn't play nice with version 1.12.34.1 and spits out;

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 38.5M  100 38.5M    0     0  2933k      0  0:00:13  0:00:13 --:--:-- 2065k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   140    0   140    0     0     47      0 --:--:--  0:00:02 --:--:--   325
100  115k  100  115k    0     0  19176      0  0:00:06  0:00:06 --:--:--  158k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1121  100  1121    0     0    414      0  0:00:02  0:00:02 --:--:--  5690
patching file src/pagespeed/automatic/Makefile
Hunk 2 FAILED 170/168.
   third_party/gflags/libgflags.a \
   third_party/giflib/libdgiflib.a \
   third_party/giflib/libgiflib_core.a \
-  third_party/icu/libicudata.a \
-  third_party/icu/libicuuc.a \
   third_party/jsoncpp/libjsoncpp.a \
-  third_party/libjpeg_turbo/libjpeg.a \
-  third_party/libjpeg_turbo/src/libjpeg_turbo.a \
-  third_party/libpng/libpng.a \
   third_party/optipng/libopngreduc.a \
   third_party/protobuf/libprotobuf_full_do_not_use.a \
   third_party/re2/libre2.a \
-  third_party/serf/libopenssl.a \
   third_party/serf/libserf.a \
-  third_party/zlib/libzlib.a \
   url/liburl_lib.a
 
 # The 'gclient' build flow uses 'xcodebuild' on Mac and 'make' on Linux.

@aleksijohansson
Copy link

@ciarans It might be that something has changed in the folder structure in version 1.12.34.1. I've fixed it once before in https://github.com/wunderkraut/image-fuzzy-alpine-nginx-pagespeed, but haven't updated that to the most up to date version yet.

@ciarans
Copy link

ciarans commented Dec 15, 2016

@aleksijohansson thanks for giving me some feedback. I would love to give debugging a the problem myself but my patch knowledge is very basic.

@ciarans
Copy link

ciarans commented Dec 15, 2016

@aleksijohansson after some research it looks like the following file has is causing the problem -
https://raw.githubusercontent.com/wunderkraut/alpine-nginx-pagespeed/master/patches/automatic_makefile.patch

@wernight
Copy link
Contributor Author

wernight commented Dec 15, 2016 via email

@ciarans
Copy link

ciarans commented Dec 15, 2016

@wernight @aleksijohansson from the work you guys did earlier I've managed to generate the following;

--- a/src/pagespeed/automatic/Makefile
+++ b/src/pagespeed/automatic/Makefile
@@ -145,8 +145,6 @@
   pagespeed/libpagespeed_thread.a \
   pagespeed/libpthread_system.a \
   pagespeed/libutil.a \
-  third_party/apr/libapr.a \
-  third_party/aprutil/libaprutil.a \
   third_party/base64/libbase64.a \
   third_party/chromium/src/base/third_party/dynamic_annotations/libdynamic_annotations.a \
   third_party/css_parser/libcss_parser.a \
@@ -158,22 +156,11 @@
   third_party/gflags/libgflags.a \
   third_party/giflib/libdgiflib.a \
   third_party/giflib/libgiflib_core.a \
-  third_party/grpc/libgpr.a \
-  third_party/grpc/libgrpc_core.a \
-  third_party/grpc/libgrpc_cpp.a \
-  third_party/hiredis/libhiredis.a \
-  third_party/icu/libicudata.a \
-  third_party/icu/libicuuc.a \
   third_party/jsoncpp/libjsoncpp.a \
-  third_party/libjpeg_turbo/libjpeg.a \
-  third_party/libjpeg_turbo/src/libjpeg_turbo.a \
-  third_party/libpng/libpng.a \
   third_party/optipng/libopngreduc.a \
   third_party/protobuf/libprotobuf_full_do_not_use.a \
   third_party/re2/libre2.a \
-  third_party/serf/libopenssl.a \
   third_party/serf/libserf.a \
-  third_party/zlib/libzlib.a \
   url/liburl_lib.a
 
 # The 'gclient' build flow uses 'xcodebuild' on Mac and 'make' on Linux.

However during the build Im now getting this;

  CC(target) out/Release/obj.target/grpc_core/third_party/grpc/src/src/core/lib/surface/init_secure.o
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined
<built-in>: note: this is the location of the previous definition
In file included from third_party/grpc/src/src/core/lib/tsi/transport_security_interface.h:38:0,
                 from third_party/grpc/src/src/core/lib/security/transport/security_connector.h:40,
                 from third_party/grpc/src/src/core/lib/security/credentials/credentials.h:45,
                 from third_party/grpc/src/src/core/lib/surface/init_secure.c:40:
/usr/include/fortify/stdlib.h: In function 'realpath':
/usr/include/fortify/stdlib.h:42:2: error: #error PATH_MAX unset. A fortified realpath will not work.
 #error PATH_MAX unset. A fortified realpath will not work.
  ^
third_party/grpc/grpc_core.target.mk:488: recipe for target 'out/Release/obj.target/grpc_core/third_party/grpc/src/src/core/lib/surface/init_secure.o' failed
make: *** [out/Release/obj.target/grpc_core/third_party/grpc/src/src/core/lib/surface/init_secure.o] Error 1

My research shows its to do with a limits.h file not being set with PATH_MAX.

Have you come across this before? Any ideas on how to get over this?

@aleksijohansson
Copy link

@ciarans Haven't seen that before. When I have time to update https://github.com/wunderkraut/image-fuzzy-alpine-nginx-pagespeed I'll let you know how it goes.

@wernight
Copy link
Contributor Author

wernight commented Apr 9, 2017

I created a automated build of ngx_pagespeed on Alpine.

@Starefossen
Copy link

+1 for better alpine support without having to patch all the things!

@tspicer
Copy link

tspicer commented May 25, 2017

Since Google is moving other Docker images to Alpine, like their Cloud SDK, they should be supporting Alpine more broadly. Most of the hacks have fixed PS to an older version. +1 to get this done right.

@nikolay
Copy link
Contributor

nikolay commented May 25, 2017

FYI, yesterday Alpine 3.6.0 got released.

@wernight
Copy link
Contributor Author

wernight commented Jul 18, 2017

I tried to upgrade and got the same issue with __strcpy_chk and similar. It seems that it's because glibc on Alpine is very limited and doesn't implement those. I wonder if there isn't a flag to disable those (really not ideal but better than having an old version). A better option would be to use strcpy_s and such (see https://stackoverflow.com/a/25811493/167897) which might be on Alpine.

I tried to disable Fortify source using --with-cc-opt='-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0' but that didn't help. Also tried CFLAGS='-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0'.

@csandanov
Copy link

Also, see apache/incubator-pagespeed-mod#1460, tried to build mod_pagespeed 1.12.34.2 on Alpine 3.6. AFAIK, old versions (<1.4) of grpc have problems with Alpine 3.6

@robov
Copy link

robov commented Jan 10, 2018

After 5 days of a very steep learning curve I am finally getting somewhere... @nberlee ,
FROM on you multistage image I create my own derivative which I then start as a container.
however, now the nginx complains that 'modsecurity' is an unknown directive.
I linked this in in the nginx compiling step, but when starting it up, it is not recognized. Am I missing a copy somewhere

It is linked in like this and it compiles well... any ideas ?

--add-module=${WRKDIR}/modsecurity/nginx/modsecurity \     
--add-module=${WRKDIR}/ngx_cache_purge-${CACHE_PURGE} \           
        --add-module=/tmp/ngx_pagespeed\

@robov
Copy link

robov commented Jan 17, 2018

Everything is working now.... BUT I receive a very wierd error
On loading the page everything goes well
on RE-Loading the page with ctrl-f5 I get a 404 (just pressing f5 again and it loads nicely again)
ANY ideas where this problem originates or how to fix it ?

@robov
Copy link

robov commented Jan 17, 2018

I have setup pagespeed on my proxy that passes the requests to the backend app server. The 404 error is generated from the app server. I think the request is looking for the pagespeed cache in the backend (where it isn;t)... but.. how to prevent that ....is the next question

@nberlee
Copy link
Contributor

nberlee commented Feb 18, 2018

I just pushed https://github.com/We-Amp/ngx-pagespeed-alpine/tree/dev

  • Pagespeed 1.13.35.2 (mod and ngx)
  • Builds on Alpine 3.7 and edge
  • Works with Nginx 1.12.2 and 1.13.8
  • Drop in replacement for nginx:alpine image. It should be exactly the same experience, making migration seamless. Butthis one contains a newer LibreSSL, Alpine, and of course Pagespeed.

@tobsch
Copy link

tobsch commented Feb 23, 2018

@nberlee great thing! do you have an idea how to convince pagespeed to link libpng statically?
In my case, I get trouble with other libraries requiring a newer version later

@nberlee
Copy link
Contributor

nberlee commented Feb 23, 2018

@tobsch Are you having problems with my Dockerfile as-is? If this is the case I would like to know.

If you only want libpng 1.6 (which i would understand), @ashishk-1 made a commit recently in incubator-pagespeed-mod:master which would make it possible. You can use patch (I haven't tested it) https://github.com/apache/incubator-pagespeed-mod/commit/7ea8d5fc141c7067c54ffa2b9fbc552c15089ca6.patch (just save it with the other patches in my branch)

Make sure to add libpng-dev in the apk add section of modpagespeed
This patch will not be incorporated in the Dockerfile sine its not part of 1.13.35.2 and I am not backporting when its not absolutely necessary

@tobsch
Copy link

tobsch commented Feb 23, 2018

@nberlee it's not "as it is" but in combination with php & such.
thanks a lot for the png patch tip: works out, after modifying the patch a bit (does not work with 1.13.35-2). Much better than a static version of libpng12!

@oschaaf
Copy link
Member

oschaaf commented Feb 23, 2018

@tobsch could you perhaps share the tweaked patch for 1.13?

@tobsch
Copy link

tobsch commented Feb 24, 2018

@oschaaf here you go: https://gist.github.com/tobsch/c59b0c9b89f51a412a57c2bf8a4cbb31

I had to change the location of zlib.h, as it is now a submodule.

@tobsch
Copy link

tobsch commented Feb 26, 2018

@oschaaf maybe you can help me with #1535 in exchange :-) ? this prevents me from using ps in production currently

@oschaaf
Copy link
Member

oschaaf commented Feb 26, 2018 via email

@tspicer
Copy link

tspicer commented May 1, 2018

curious if there has been any progress. seems like things were close but got stuck.

@nberlee
Copy link
Contributor

nberlee commented May 1, 2018

https://github.com/We-Amp/ngx-pagespeed-alpine
All changes of dev are now merged in master. I was running dev in production for some time.... (also with nginx 1.14.0

I will contact @oschaaf to discuss to create something on Dockerhub..

@oschaaf
Copy link
Member

oschaaf commented May 1, 2018

@nberlee can you ping me at oschaaf@we-amp.com?

@tspicer
Copy link

tspicer commented May 30, 2018

Any update? Also, will these changes be packaged into the base ngx build or is the model to provide a docker image with patches? Would prefer a stable ngx alpine build without docker wrapper.

@nberlee
Copy link
Contributor

nberlee commented May 30, 2018

@tspicer
Copy link

tspicer commented May 31, 2018

@nberlee so the solution is to use the actual docker build and all the associated patches from https://github.com/We-Amp/ngx-pagespeed-alpine rather than getting a ngx_pagespeed that can be used outside of that setup? In the case of someone having their own nginx docker build process or using an alternate project, we will need to disassemble the docker file and assets from We-Amp to understand how to get this functional. Am understanding that correctly?

@nberlee
Copy link
Contributor

nberlee commented May 31, 2018

@tspicer Your aim was to have an apk in the alpine store if I read your comment correctly?
I think that would not be to hard to create or get it accepted in the alpine-community repo, so feel free to do so. It is not uncommon for packages in the alpine repository to have patches because of musl. I don't expect from the ngx_pagespeed to incorporate the patches, but feel free to create PR's to ngx_pagespeed ot make it possible to build it by default on alpine without sacrificing libc distributions.

I am sorry I raised your expectation I would make or maintain such a thing. However, as docker is build on layers you can easily add stuff to the compiled docker image.

FROM pagespeed/nginx-pagespeed:stable
apk add --no-cache <my-packages>

@oschaaf
Copy link
Member

oschaaf commented May 31, 2018

@tspicer @nberlee So our initial goals with the patches was to incorporate them into mod_pagespeed, but priorities changed and we didn't wrap up. But actually some of the more complex changes already actually landed to make building possible/easier for Alpine (& FreeBSD) (e.g: upgrades for grpc / libpng).

Looking at them, the remaining patches seem pretty small and mundane. One of them would have to be upstreamed to Chromium, the others can probably be merged into mod_pagespeed without any problems --- except for the Makefile patch, which may need some consideration. I can't promise any timelines, but I'll see what I can do, hopefully in the next couple of weeks, to get the required level of patching for Alpine down to 0. One concern I have going forward though is that we Alpine is not tested in CI.

@tspicer
Copy link

tspicer commented May 31, 2018

@nberlee not the APK store, but just being able to compile as I would for another OS. At the moment the process to install is tightly coupled into a specific Dockerfile. If you are compiling from nginx source with alternate modules/packages and libraries, your choice is to 1) copy the docker file as provided and modify the nginx build as applicable, then customize any other parts that are warranted or 2) deconstruct the Dockerfile, grab the patches and attempt to incorporate into your own build.

So no expectations were set by you :)
I just want to make sure what you have referenced is the fix and in basically closes this issue.

thanks @oschaaf for clarifying

@csandanov
Copy link

csandanov commented Aug 3, 2018

PSOL compilation takes way too much time (~35 min on travis), so I moved it out to a separate repository before the official release become available and just download the archive (100M of objects required for nginx module compilation) during nginx build, see example. Useful if you maintain your own alpine-based nginx image and want to add pagespeed module.

@nberlee
Copy link
Contributor

nberlee commented Aug 3, 2018

@csandanov If you would implement docker layer caching in travis (which is ok, with a tagged versions in a multi-stage docker file), builds would fly if you change something on the nginx.

oschaaf pushed a commit that referenced this issue Oct 8, 2018
…inline), (directory structure organised for DockerHub build compatibility). (#1598)

Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busy box. Alpine is therefor the most logical OS base for Docker Images.

Although it does not fix #1181 completely, it helps to overcome the problems of building the PSOL on Alpine,
@oschaaf
Copy link
Member

oschaaf commented Oct 8, 2018

Accidentally closed this while merging #1598.
Re-opening this, while the bar has been substantially lowered, this isn't completely done yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.