varnish / docker-varnish

Official docker image
https://hub.docker.com/_/varnish
82 stars 34 forks source link

Provide Alpine based variant #2

Closed J0WI closed 3 years ago

J0WI commented 5 years ago

Would be great to have a variant based on the lightweight Alpine Linux base image.

Alpine Linux is a Linux distribution built around musl libc and BusyBox. The image is only 5 MB in size and has access to a package repository that is much more complete than other BusyBox based images. This makes Alpine Linux a great image base for utilities and even production applications. Read more about Alpine Linux here and you can see how their mantra fits in right at home with Docker images.

https://hub.docker.com/_/alpine

Alpine currently requires some tiny patches to build Varnish on musl-libc. This could be fixed upstream: https://git.alpinelinux.org/aports/tree/main/varnish?h=master

gquintard commented 5 years ago

Hi,

Some context: I upstreamed a couple of patches last year I believe, but then we broke that again, and Alpine keeps patching the packages without upstreaming them. The plan is to realign upstream and Alpine for the september release, and possibly add some CI to avoid things breaking again.

But, even with the patches, make check doesn't fully passes on Alpine, and this is an upstream issue, and we can't do anything until that is fixed.

I will keep this ticket around because I know you won't be the last to ask about it, but work needs to be done upstream first before it becomes relevant.

martinsvoboda commented 3 years ago

@gquintard I found an unofficial Varnish image based on Alpine. https://github.com/Hermsi1337/docker-varnish/blob/master/varnish-65/Dockerfile. Are problems with make check still relevant?

gquintard commented 3 years ago

hi, actually, the varnish project now tests and even packages for alpine (but doesn't distribute the apks) so the compilation issues are behind us.

and I've just checked now and packagecloud apparently supports alpine, so it worth revisiting. But packages need to be pushed befofe we do anything here

J0WI commented 3 years ago

Is there an issue to track the apk distribution? In the meantime varnish could be build from source in the Dockerfile.

gquintard commented 3 years ago

looks like packagecloud.io is still the blocker and doesn't really support apk files, so yes, building the files in the Dockerfile is possibly the best option. And there's already a script for that: https://github.com/varnishcache/varnish-cache/blob/master/.circleci/make-apk-packages.sh

Really, all that is needed is a kind soul with the bandwidth to actually do the work and open a PR

J0WI commented 3 years ago

I can provide a poc Dockerfile. How do you plan to integrate this with your populate.sh? The entrypoint scripts need some adjustments to work with the self compiled version.

Dockerfile ```Dockerfile FROM alpine:3.14 ENV VARNISH_VERSION 6.6.0 ENV VARNISH_SIZE 100M ENV VARNISH_DOWNLOAD_URL https://varnish-cache.org/_downloads/varnish-${VARNISH_VERSION}.tgz ENV VARNISH_SHA512 0f52e94dd866a7cf141f9333a9169b396627f169907acb2d64f18dcac3188f9d9f1e72ea9eb9f2c0c19a5f53df0c90446041eb2b1e52f4756ea257efb329d0d1 RUN set -eux; \ \ apk add --no-cache --virtual .build-deps \ autoconf \ automake \ ca-certificates \ cpio \ gcc \ libc-dev \ libedit-dev \ libgcc \ libtool \ libunwind-dev \ linux-headers \ make \ ncurses-dev \ pcre-dev \ py3-docutils \ py3-sphinx \ ; \ wget -O varnish.tar.gz "$VARNISH_DOWNLOAD_URL"; \ echo "$VARNISH_SHA512 *varnish.tar.gz" | sha512sum -c -; \ mkdir -p /usr/src/varnish; \ tar -xf varnish.tar.gz -C /usr/src/varnish --strip-components=1; \ rm varnish.tar.gz; \ cd /usr/src/varnish; \ ./autogen.sh; \ ./configure \ --with-unwind \ --without-jemalloc \ ; \ make -C /usr/src/varnish -j "$(nproc)"; \ make -C /usr/src/varnish install; \ rm -rf /usr/src/varnish; \ \ runDeps="$( \ scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )"; \ apk add --no-network --virtual .varnish-rundeps $runDeps; \ apk del --no-network .build-deps; \ \ varnishd -V COPY scripts/ /usr/local/bin/ ENTRYPOINT ["/usr/local/bin/docker-varnish-entrypoint"] EXPOSE 80 8443 CMD [] ```
gquintard commented 3 years ago

cheers. Shouldn't we build packages and install those, or is that jumping through too many hoops?

J0WI commented 3 years ago

You just said that your infrastructure cant' distribute apk packages

gquintard commented 3 years ago

Indeed, but it does build them. So we can create the APK files and install those, all in the Dockerfile.

I usually avoid to litter my root filesystems with unpackaged files, but in the docker case, it may not be that important, I don't know.

-- Guillaume Quintard

On Sat, Jul 3, 2021, 04:18 J0WI @.***> wrote:

You just said that your infrastructure cant' distribute apk packages

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/varnish/docker-varnish/issues/2#issuecomment-873392004, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA42AKPTQ4JUM7264SZWTITTV3WY5ANCNFSM4H7QMEEA .

J0WI commented 3 years ago

Indeed, but it does build them.

Including ARM etc? If you provide a download url I'll update the POC.

gquintard commented 3 years ago

here's an example: https://app.circleci.com/pipelines/github/varnishcache/varnish-cache/2471/workflows/bc802559-f3e8-4e17-9e65-244d144d7e04

we'd have to do build the packages in here though, because we can't trust circleci to keep the artifacts around

J0WI commented 3 years ago

here's an example

it's not public.

gquintard commented 3 years ago

arf, it should be public, but will require a circleci account. The script building the packages is here: https://github.com/varnishcache/varnish-cache/blob/master/.circleci/make-apk-packages.sh and relying on this repo: https://github.com/varnishcache/pkg-varnish-cache/tree/master/alpine

gquintard commented 3 years ago

now live on the hub