From 98988f5149233a8790b65e45e40d3e787f552be1 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Fri, 19 Nov 2021 02:00:05 +0000 Subject: [PATCH] Refactor: Tidy up variants definition and Dockerfile template --- generate/definitions/VARIANTS.ps1 | 4 +-- generate/templates/Dockerfile.ps1 | 44 ++++++++++---------------- variants/4.1.4-ubuntu-16.04/Dockerfile | 41 ++++++++++-------------- 3 files changed, 36 insertions(+), 53 deletions(-) diff --git a/generate/definitions/VARIANTS.ps1 b/generate/definitions/VARIANTS.ps1 index ec908e9..9ed03ca 100644 --- a/generate/definitions/VARIANTS.ps1 +++ b/generate/definitions/VARIANTS.ps1 @@ -3,11 +3,11 @@ $VARIANTS = @( @{ _metadata = @{ components = @( 'varnishdashboard' ) - distro = 'ubuntu' - distro_version = '16.04' platforms = 'linux/386,linux/amd64,linux/arm/v7,linux/arm64,linux/s390x' VARNISH_AGENT_VERSION = '4.1.4' VARNISH_DASHBOARD_COMMIT = "e2cc1c854941c9fac18bdfedba2819fa766a5549" + # distro = 'ubuntu' + # distro_version = '16.04' } tag = '4.1.4-ubuntu-16.04' tag_as_latest = $true diff --git a/generate/templates/Dockerfile.ps1 b/generate/templates/Dockerfile.ps1 index 3c676a3..239412d 100644 --- a/generate/templates/Dockerfile.ps1 +++ b/generate/templates/Dockerfile.ps1 @@ -1,43 +1,34 @@ @" FROM ubuntu:16.04 -RUN VARNISH_AGENT_VERSION="$( $VARIANT['_metadata']['VARNISH_AGENT_VERSION'] )" \ - && VARNISH_DASHBOARD_COMMIT="e2cc1c854941c9fac18bdfedba2819fa766a5549" \ - && buildDeps="automake build-essential curl ca-certificates libvarnishapi-dev libmicrohttpd-dev libcurl4-gnutls-dev pkg-config python-docutils git" \ - && runDeps="libvarnishapi1 libmicrohttpd10 libcurl4-gnutls-dev" \ - -"@ + @' - \ - # Install Varnish Agent - && apt-get update \ - && apt-get install -y --no-install-recommends $buildDeps \ - && curl -o /tmp/vagent2.tar.gz -SL https://github.com/varnish/vagent2/archive/${VARNISH_AGENT_VERSION}.tar.gz \ - && tar -zxvf /tmp/vagent2.tar.gz -C /tmp/ \ - && rm -rf /tmp/vagent2.tar.gz \ - && cd /tmp/vagent2-${VARNISH_AGENT_VERSION} \ +RUN apt-get update \ + && buildDeps="wget ca-certificates git automake build-essential libvarnishapi-dev libmicrohttpd-dev libcurl4-gnutls-dev pkg-config python-docutils" \ + && apt-get install --no-install-recommends -y `$buildDeps \ + && VARNISH_AGENT_VERSION="$( $VARIANT['_metadata']['VARNISH_AGENT_VERSION'] )" \ + && wget -qO- "https://github.com/varnish/vagent2/archive/`$VARNISH_AGENT_VERSION.tar.gz" > /tmp/vagent2.tar.gz \ + && tar -C /tmp -zxvf /tmp/vagent2.tar.gz \ + && cd "/tmp/vagent2-`$VARNISH_AGENT_VERSION" \ && ./autogen.sh \ && ./configure \ && make \ && make install \ && ldconfig \ + && rm -rf /tmp/vagent2.tar.gz \ \ - # Install Varnish Dashboard - && mkdir -p /var/www/html \ - && cd /var/www/html \ - && git clone https://github.com/brandonwamboldt/varnish-dashboard.git \ - && cd varnish-dashboard \ - && git checkout ${VARNISH_DASHBOARD_COMMIT} \ + && VARNISH_DASHBOARD_COMMIT="$( $VARIANT['_metadata']['VARNISH_DASHBOARD_COMMIT'] )" \ + && git clone https://github.com/brandonwamboldt/varnish-dashboard.git /var/www/html/varnish-dashboard \ + && cd /var/www/html/varnish-dashboard \ + && git checkout "`$VARNISH_DASHBOARD_COMMIT" \ + && rm -rf .git \ \ - # Cleanup - && apt-get purge -y --auto-remove $buildDeps \ + && apt-get purge --auto-remove -y `$buildDeps \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ \ - # Install runtime dependencies && apt-get update \ - && apt-get install -y --no-install-recommends $runDeps \ + && runDeps="libvarnishapi1 libmicrohttpd10 libcurl4-gnutls-dev" \ + && apt-get install --no-install-recommends -y `$runDeps \ \ - # Cleanup && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -52,5 +43,4 @@ STOPSIGNAL SIGKILL ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["varnish-agent", "-d"] - -'@ +"@ diff --git a/variants/4.1.4-ubuntu-16.04/Dockerfile b/variants/4.1.4-ubuntu-16.04/Dockerfile index cf63c56..2a1dcc8 100644 --- a/variants/4.1.4-ubuntu-16.04/Dockerfile +++ b/variants/4.1.4-ubuntu-16.04/Dockerfile @@ -1,40 +1,33 @@ FROM ubuntu:16.04 -RUN VARNISH_AGENT_VERSION="4.1.4" \ - && VARNISH_DASHBOARD_COMMIT="e2cc1c854941c9fac18bdfedba2819fa766a5549" \ - && buildDeps="automake build-essential curl ca-certificates libvarnishapi-dev libmicrohttpd-dev libcurl4-gnutls-dev pkg-config python-docutils git" \ - && runDeps="libvarnishapi1 libmicrohttpd10 libcurl4-gnutls-dev" \ - \ - # Install Varnish Agent - && apt-get update \ - && apt-get install -y --no-install-recommends $buildDeps \ - && curl -o /tmp/vagent2.tar.gz -SL https://github.com/varnish/vagent2/archive/${VARNISH_AGENT_VERSION}.tar.gz \ - && tar -zxvf /tmp/vagent2.tar.gz -C /tmp/ \ - && rm -rf /tmp/vagent2.tar.gz \ - && cd /tmp/vagent2-${VARNISH_AGENT_VERSION} \ +RUN apt-get update \ + && buildDeps="wget ca-certificates git automake build-essential libvarnishapi-dev libmicrohttpd-dev libcurl4-gnutls-dev pkg-config python-docutils" \ + && apt-get install --no-install-recommends -y $buildDeps \ + && VARNISH_AGENT_VERSION="4.1.4" \ + && wget -qO- "https://github.com/varnish/vagent2/archive/$VARNISH_AGENT_VERSION.tar.gz" > /tmp/vagent2.tar.gz \ + && tar -C /tmp -zxvf /tmp/vagent2.tar.gz \ + && cd "/tmp/vagent2-$VARNISH_AGENT_VERSION" \ && ./autogen.sh \ && ./configure \ && make \ && make install \ && ldconfig \ + && rm -rf /tmp/vagent2.tar.gz \ \ - # Install Varnish Dashboard - && mkdir -p /var/www/html \ - && cd /var/www/html \ - && git clone https://github.com/brandonwamboldt/varnish-dashboard.git \ - && cd varnish-dashboard \ - && git checkout ${VARNISH_DASHBOARD_COMMIT} \ + && VARNISH_DASHBOARD_COMMIT="e2cc1c854941c9fac18bdfedba2819fa766a5549" \ + && git clone https://github.com/brandonwamboldt/varnish-dashboard.git /var/www/html/varnish-dashboard \ + && cd /var/www/html/varnish-dashboard \ + && git checkout "$VARNISH_DASHBOARD_COMMIT" \ + && rm -rf .git \ \ - # Cleanup - && apt-get purge -y --auto-remove $buildDeps \ + && apt-get purge --auto-remove -y $buildDeps \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ \ - # Install runtime dependencies && apt-get update \ - && apt-get install -y --no-install-recommends $runDeps \ + && runDeps="libvarnishapi1 libmicrohttpd10 libcurl4-gnutls-dev" \ + && apt-get install --no-install-recommends -y $runDeps \ \ - # Cleanup && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -48,4 +41,4 @@ RUN chmod +x /docker-entrypoint.sh STOPSIGNAL SIGKILL ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["varnish-agent", "-d"] +CMD ["varnish-agent", "-d"] \ No newline at end of file