docker-perl icon indicating copy to clipboard operation
docker-perl copied to clipboard

`alpine` variant

Open PeterMartini opened this issue 8 years ago • 10 comments

Like the tin says, an alpine version would be very useful

PeterMartini avatar Apr 07 '16 01:04 PeterMartini

I have an example Dockerfile.

I don't know how to embed it in generate.pl properly? Maybe we should introduce Dockerfile.template and Dockerfile.template-alpine or similar?

There make test_harness have some failing testcase related non UTF-8 locales.

FROM alpine:latest
MAINTAINER Peter Martini <[email protected]>

RUN mkdir -p /usr/src/perl
COPY *.patch /usr/src/perl/
WORKDIR /usr/src/perl

RUN set -x \
    && NPROC=$(getconf _NPROCESSORS_ONLN) \
    && apk add --no-cache --virtual .build-deps \
        curl procps tar build-base \
    && curl -SL https://cpan.metacpan.org/authors/id/S/SH/SHAY/perl-5.22.1.tar.bz2 -o perl-5.22.1.tar.bz2 \
    && echo '29f9b320b0299577a3e1d02e9e8ef8f26f160332 *perl-5.22.1.tar.bz2' | sha1sum -c - \
    && tar --strip-components=1 -xjf perl-5.22.1.tar.bz2 -C /usr/src/perl \
    && rm perl-5.22.1.tar.bz2 \
    && cat *.patch | patch -p1 \
    && ./Configure -Duse64bitall -Duseshrplib  -des \
    && make -j$NPROC \
    && TEST_JOBS=$NPROC make test_harness \
    && make install \
    && cd /usr/src \
    && curl -LO https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm \
    && chmod +x cpanm \
    && ./cpanm App::cpanminus \
    && rm -fr ./cpanm /root/.cpanm /usr/src/perl /tmp/* \
    && apk del .build-deps

WORKDIR /root

CMD ["perl5.22.1","-de0"]

ncopa avatar Apr 07 '16 14:04 ncopa

I'll look into it this weekend :+1:

zakame avatar Apr 08 '16 16:04 zakame

So I tried this evening, and read a bit more about why the failing tests related to locale. Turns out that musl-libc still has some open issues regarding locales:

  • http://wiki.musl-libc.org/wiki/Open_Issues notes about C locale conformance
  • http://www.openwall.com/lists/musl/2014/08/01/1 describes the locale system in 1.1.4, how it finds locale files, and how it deals with bad names

For my initial alpine build, I've settled on disabling setlocale() entirely, so I expect some issues; there ought to be another way to solve this.

At the very least, the resulting image size for perl:alpine (5.22.1) is very promising:

perl                alpine              5c08e6b31771        About an hour ago   204.5 MB
perl                latest              b17836574ef6        5 months ago        656.4 MB

If using @ncopa's example Dockerfile (which deletes the installed .build-deps after installing cpanm,) it would be possible to bring down the alpine image to just around 50MB; I'll probably go with that setup later, leaving only curl and make so that CPAN installs of pure-Perl modules could work.

zakame avatar Apr 09 '16 14:04 zakame

Removing build deps:

REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
perl                alpine              d93b2855ed9a        About a minute ago   52.61 MB

I retained make though as a bare minimum so cpanm can install pure-Perl modules.

zakame avatar Apr 22 '16 04:04 zakame

Coming back to this again. It seems ok building with 5.22.4, so now I'm testing building against 5.24.2.

There's still some errors for some parts still trying to find setlocale(), so I'm gonna ask #p5p for help.

zakame avatar Jul 30 '17 10:07 zakame

Any update?

spumer avatar May 22 '18 15:05 spumer

@spumer thanks for asking. Unfortunately I haven't gotten much feedback from #p5p last time and could not continue further. I doubt that there are specific changes for this on the upcoming 5.28 release as well, but I'll find some time to confirm.

zakame avatar May 23 '18 05:05 zakame

Perl 5.32 now seems to build and test fine on Alpine without modification :tada:

I'll do a bit more testing this week and keep some manually-generated Dockerfiles for this for publishing on Hub.

zakame avatar Sep 08 '20 10:09 zakame

For anyone who wants to help testing, I've pushed image build for 5.32-alpine and 5.32-alpine-threaded to the hub:

docker pull zakame/perl:5.32-alpine
docker pull zakame/perl:5.32-alpine-threaded

zakame avatar Sep 08 '20 12:09 zakame

Revisiting this one - I think we could just push out a :alpine image without issue, as long as we document the obvious issues of glibc vs musl differences.

zakame avatar Aug 06 '22 16:08 zakame