diff --git a/deploy/varnish/Dockerfile b/deploy/varnish/Dockerfile index 6de3973..d20abc0 100644 --- a/deploy/varnish/Dockerfile +++ b/deploy/varnish/Dockerfile @@ -1,31 +1,43 @@ -FROM debian:trixie-slim +# --- Stage 1: build varnish + modules --- +FROM debian:trixie-slim AS builder ARG VARNISH_VERSION=8.0.0 ARG VARNISH_MODULES_VERSION=0.27.0 -# potrzebne narzędzia do kompilacji RUN apt-get update && apt-get install -y \ curl build-essential automake autoconf libtool pkg-config python3-sphinx \ git ca-certificates \ - libpcre2-dev \ - libedit-dev \ + libpcre2-dev libedit-dev \ && rm -rf /var/lib/apt/lists/* -# instalacja varnish +# build varnish RUN curl -fsSL https://varnish-cache.org/_downloads/varnish-${VARNISH_VERSION}.tgz -o varnish.tar.gz \ && tar xzf varnish.tar.gz \ && cd varnish-${VARNISH_VERSION} \ && ./configure && make -j$(nproc) && make install \ && cd .. && rm -rf varnish-${VARNISH_VERSION} varnish.tar.gz -# instalacja varnish-modules (w tym vsthrottle) +# build varnish-modules RUN curl -fsSL https://github.com/varnish/varnish-modules/releases/download/${VARNISH_MODULES_VERSION}/varnish-modules-${VARNISH_MODULES_VERSION}.tar.gz -o modules.tar.gz \ && tar xzf modules.tar.gz \ && cd varnish-modules-${VARNISH_MODULES_VERSION} \ && ./configure && make -j$(nproc) && make install \ && cd .. && rm -rf varnish-modules-${VARNISH_MODULES_VERSION} modules.tar.gz -# katalog na konfigurację +# --- Stage 2: runtime --- +FROM debian:trixie-slim AS runtime + +# tylko to co potrzebne do uruchomienia varnish +RUN apt-get update && apt-get install -y \ + libpcre2-8-0 \ + libedit2 \ + ca-certificates \ + curl \ + && rm -rf /var/lib/apt/lists/* + +# kopiujemy binaria i moduły z buildera +COPY --from=builder /usr/local /usr/local + WORKDIR /etc/varnish COPY default.vcl /etc/varnish/