From 46016bae5cf1466cab24383c4f1861e4957093ad Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Mon, 29 Sep 2025 21:53:08 +1000 Subject: [PATCH] refactor: move download logic from Dockerfiles to build.sh scripts Move complex download commands from Dockerfiles to build.sh scripts for consistency: - pgbouncer_exporter, bind_exporter, exportarr, node_exporter, postgres_exporter: GitHub downloads - vmagent, vmalert: VictoriaMetrics vmutils downloads - vminsert, vmselect, vmstorage: VictoriaMetrics cluster downloads All Dockerfiles now follow the simple template pattern with download logic properly contained in build scripts. --- rpms/bind_exporter/Dockerfile | 5 +---- rpms/bind_exporter/resources/build.sh | 4 ++++ rpms/exportarr/Dockerfile | 5 +---- rpms/exportarr/resources/build.sh | 4 ++++ rpms/node_exporter/Dockerfile | 4 +--- rpms/node_exporter/resources/build.sh | 4 ++++ rpms/pgbouncer_exporter/Dockerfile | 5 +---- rpms/pgbouncer_exporter/resources/build.sh | 4 ++++ rpms/postgres_exporter/Dockerfile | 4 +--- rpms/postgres_exporter/resources/build.sh | 4 ++++ rpms/vmagent/Dockerfile | 6 +----- rpms/vmagent/resources/build.sh | 5 +++++ rpms/vmalert/Dockerfile | 6 +----- rpms/vmalert/resources/build.sh | 5 +++++ rpms/vminsert/Dockerfile | 6 +----- rpms/vminsert/resources/build.sh | 5 +++++ rpms/vmselect/Dockerfile | 6 +----- rpms/vmselect/resources/build.sh | 5 +++++ rpms/vmstorage/Dockerfile | 6 +----- rpms/vmstorage/resources/build.sh | 5 +++++ 20 files changed, 55 insertions(+), 43 deletions(-) diff --git a/rpms/bind_exporter/Dockerfile b/rpms/bind_exporter/Dockerfile index c550395..8d00407 100644 --- a/rpms/bind_exporter/Dockerfile +++ b/rpms/bind_exporter/Dockerfile @@ -11,11 +11,8 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN curl --output - -L https://github.com/prometheus-community/bind_exporter/releases/download/v${PACKAGE_VERSION}/bind_exporter-${PACKAGE_VERSION}.linux-amd64.tar.gz | tar --strip-components=1 -xzf - - # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/bind_exporter/resources/build.sh b/rpms/bind_exporter/resources/build.sh index ae730e3..c7400d7 100755 --- a/rpms/bind_exporter/resources/build.sh +++ b/rpms/bind_exporter/resources/build.sh @@ -1,2 +1,6 @@ #!/usr/bin/bash + +# Download the required files +curl --output - -L https://github.com/prometheus-community/bind_exporter/releases/download/v${PACKAGE_VERSION}/bind_exporter-${PACKAGE_VERSION}.linux-amd64.tar.gz | tar --strip-components=1 -xzf - + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/exportarr/Dockerfile b/rpms/exportarr/Dockerfile index 7538961..8d00407 100644 --- a/rpms/exportarr/Dockerfile +++ b/rpms/exportarr/Dockerfile @@ -11,11 +11,8 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN curl --output - -L https://github.com/onedr0p/exportarr/releases/download/v${PACKAGE_VERSION}/exportarr_${PACKAGE_VERSION}_linux_amd64.tar.gz | tar --strip-components=1 -xzf - - # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/exportarr/resources/build.sh b/rpms/exportarr/resources/build.sh index ae730e3..4d80f3a 100755 --- a/rpms/exportarr/resources/build.sh +++ b/rpms/exportarr/resources/build.sh @@ -1,2 +1,6 @@ #!/usr/bin/bash + +# Download the required files +curl --output - -L https://github.com/onedr0p/exportarr/releases/download/v${PACKAGE_VERSION}/exportarr_${PACKAGE_VERSION}_linux_amd64.tar.gz | tar --strip-components=1 -xzf - + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/node_exporter/Dockerfile b/rpms/node_exporter/Dockerfile index 585050c..6d5dcec 100644 --- a/rpms/node_exporter/Dockerfile +++ b/rpms/node_exporter/Dockerfile @@ -11,11 +11,9 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN curl --output - -L https://github.com/prometheus/node_exporter/releases/download/v${PACKAGE_VERSION}/node_exporter-${PACKAGE_VERSION}.linux-amd64.tar.gz | tar --strip-components=1 -xzf - # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/node_exporter/resources/build.sh b/rpms/node_exporter/resources/build.sh index ae730e3..4806f50 100755 --- a/rpms/node_exporter/resources/build.sh +++ b/rpms/node_exporter/resources/build.sh @@ -1,2 +1,6 @@ #!/usr/bin/bash + +# Download the required files +curl --output - -L https://github.com/prometheus/node_exporter/releases/download/v${PACKAGE_VERSION}/node_exporter-${PACKAGE_VERSION}.linux-amd64.tar.gz | tar --strip-components=1 -xzf - + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/pgbouncer_exporter/Dockerfile b/rpms/pgbouncer_exporter/Dockerfile index 853637d..8d00407 100644 --- a/rpms/pgbouncer_exporter/Dockerfile +++ b/rpms/pgbouncer_exporter/Dockerfile @@ -11,11 +11,8 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN curl --output - -L https://github.com/prometheus-community/pgbouncer_exporter/releases/download/v${PACKAGE_VERSION}/pgbouncer_exporter-${PACKAGE_VERSION}.linux-amd64.tar.gz | tar --strip-components=1 -xzf - - # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/pgbouncer_exporter/resources/build.sh b/rpms/pgbouncer_exporter/resources/build.sh index ae730e3..32dd9d3 100755 --- a/rpms/pgbouncer_exporter/resources/build.sh +++ b/rpms/pgbouncer_exporter/resources/build.sh @@ -1,2 +1,6 @@ #!/usr/bin/bash + +# Download the required files +curl --output - -L https://github.com/prometheus-community/pgbouncer_exporter/releases/download/v${PACKAGE_VERSION}/pgbouncer_exporter-${PACKAGE_VERSION}.linux-amd64.tar.gz | tar --strip-components=1 -xzf - + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/postgres_exporter/Dockerfile b/rpms/postgres_exporter/Dockerfile index f50a744..6d5dcec 100644 --- a/rpms/postgres_exporter/Dockerfile +++ b/rpms/postgres_exporter/Dockerfile @@ -11,11 +11,9 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN curl --output - -L https://github.com/prometheus-community/postgres_exporter/releases/download/v${PACKAGE_VERSION}/postgres_exporter-${PACKAGE_VERSION}.linux-amd64.tar.gz | tar --strip-components=1 -xzf - # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/postgres_exporter/resources/build.sh b/rpms/postgres_exporter/resources/build.sh index ae730e3..fd257fd 100755 --- a/rpms/postgres_exporter/resources/build.sh +++ b/rpms/postgres_exporter/resources/build.sh @@ -1,2 +1,6 @@ #!/usr/bin/bash + +# Download the required files +curl --output - -L https://github.com/prometheus-community/postgres_exporter/releases/download/v${PACKAGE_VERSION}/postgres_exporter-${PACKAGE_VERSION}.linux-amd64.tar.gz | tar --strip-components=1 -xzf - + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/vmagent/Dockerfile b/rpms/vmagent/Dockerfile index b48cbc2..6d5dcec 100644 --- a/rpms/vmagent/Dockerfile +++ b/rpms/vmagent/Dockerfile @@ -11,13 +11,9 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN wget -O /app/vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz \ - https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz && \ - tar xf vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/vmagent/resources/build.sh b/rpms/vmagent/resources/build.sh index ae730e3..cce18fd 100755 --- a/rpms/vmagent/resources/build.sh +++ b/rpms/vmagent/resources/build.sh @@ -1,2 +1,7 @@ #!/usr/bin/bash + +# Download the required files +wget -O /app/vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz +tar xf vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/vmalert/Dockerfile b/rpms/vmalert/Dockerfile index b48cbc2..6d5dcec 100644 --- a/rpms/vmalert/Dockerfile +++ b/rpms/vmalert/Dockerfile @@ -11,13 +11,9 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN wget -O /app/vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz \ - https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz && \ - tar xf vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/vmalert/resources/build.sh b/rpms/vmalert/resources/build.sh index ae730e3..cce18fd 100755 --- a/rpms/vmalert/resources/build.sh +++ b/rpms/vmalert/resources/build.sh @@ -1,2 +1,7 @@ #!/usr/bin/bash + +# Download the required files +wget -O /app/vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz +tar xf vmutils-linux-amd64-v${PACKAGE_VERSION}.tar.gz + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/vminsert/Dockerfile b/rpms/vminsert/Dockerfile index bc58b69..6d5dcec 100644 --- a/rpms/vminsert/Dockerfile +++ b/rpms/vminsert/Dockerfile @@ -11,13 +11,9 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN wget -O /app/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz \ - https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz && \ - tar xf victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/vminsert/resources/build.sh b/rpms/vminsert/resources/build.sh index ae730e3..1de62ab 100755 --- a/rpms/vminsert/resources/build.sh +++ b/rpms/vminsert/resources/build.sh @@ -1,2 +1,7 @@ #!/usr/bin/bash + +# Download the required files +wget -O /app/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz +tar xf victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/vmselect/Dockerfile b/rpms/vmselect/Dockerfile index bc58b69..6d5dcec 100644 --- a/rpms/vmselect/Dockerfile +++ b/rpms/vmselect/Dockerfile @@ -11,13 +11,9 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN wget -O /app/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz \ - https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz && \ - tar xf victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/vmselect/resources/build.sh b/rpms/vmselect/resources/build.sh index ae730e3..1de62ab 100755 --- a/rpms/vmselect/resources/build.sh +++ b/rpms/vmselect/resources/build.sh @@ -1,2 +1,7 @@ #!/usr/bin/bash + +# Download the required files +wget -O /app/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz +tar xf victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/vmstorage/Dockerfile b/rpms/vmstorage/Dockerfile index bc58b69..6d5dcec 100644 --- a/rpms/vmstorage/Dockerfile +++ b/rpms/vmstorage/Dockerfile @@ -11,13 +11,9 @@ ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} ARG PACKAGE_VERSION ENV PACKAGE_VERSION=${PACKAGE_VERSION} -# Copy nfpm.yaml from the context into the container +# Copy resources from the context into the container COPY resources /app/resources -# Download the required files -RUN wget -O /app/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz \ - https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz && \ - tar xf victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz # Default command to build RPMs CMD /app/resources/build.sh diff --git a/rpms/vmstorage/resources/build.sh b/rpms/vmstorage/resources/build.sh index ae730e3..1de62ab 100755 --- a/rpms/vmstorage/resources/build.sh +++ b/rpms/vmstorage/resources/build.sh @@ -1,2 +1,7 @@ #!/usr/bin/bash + +# Download the required files +wget -O /app/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v${PACKAGE_VERSION}/victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz +tar xf victoria-metrics-linux-amd64-v${PACKAGE_VERSION}-cluster.tar.gz + nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm