From 34575a4d4b43c2e0d1c52d99d3e44219a29dda98 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 31 May 2026 20:24:29 +0100 Subject: [PATCH 01/17] try clean env for cache --- netdisco-backend/Dockerfile | 9 ++++++--- netdisco-base/Dockerfile | 25 ++++++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index a03224f..374a403 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -5,6 +5,7 @@ FROM localhost:5000/netdisco:${COMMITTISH}-base USER root RUN --mount=type=cache,target=/var/cache/apk \ + COMMITTISH= \ apk add \ ca-certificates \ curl \ @@ -13,7 +14,8 @@ RUN --mount=type=cache,target=/var/cache/apk \ tar WORKDIR /var/lib/postgresql/netdisco-sql -RUN curl -sLO "https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql" +RUN COMMITTISH= \ + curl -sLO "https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql" USER netdisco:netdisco WORKDIR /home/netdisco @@ -23,7 +25,8 @@ WORKDIR /home/netdisco # in which case docker will simply re-download the previous version (the current release) ADD https://github.com/netdisco/netdisco-mibs/raw/refs/heads/master/VERSION /tmp/netdisco-mibs-version -RUN curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ +RUN COMMITTISH= \ + curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ grep browser_download_url | xargs printf "curl -sL %s\n" | tail -1 | \ sh | tar -zxf - @@ -43,7 +46,7 @@ ENV UV_NO_MANAGED_PYTHON=true \ UV_NO_DEV=1 COPY --chown=netdisco:netdisco netdisco-updatedb.sh /home/netdisco/bin/ -RUN chmod +x /home/netdisco/bin/netdisco-updatedb.sh +RUN COMMITTISH= chmod +x /home/netdisco/bin/netdisco-updatedb.sh LABEL org.label-schema.name="netdisco-backend" \ org.label-schema.description="Polling Daemon for Netdisco" diff --git a/netdisco-base/Dockerfile b/netdisco-base/Dockerfile index 83f6393..28ef9de 100644 --- a/netdisco-base/Dockerfile +++ b/netdisco-base/Dockerfile @@ -29,6 +29,7 @@ FROM docker.io/alpine:latest AS netdisco-builder-image ARG CACHE_BUST_OS=1 RUN --mount=type=cache,target=/var/cache/apk \ + NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ apk update && \ apk add \ linux-headers \ @@ -60,7 +61,8 @@ RUN --mount=type=cache,target=/var/cache/apk \ apk fix --no-cache perl perl-dev WORKDIR /tmp -RUN curl -sL -o /tmp/cpanm https://cpanmin.us/ && \ +RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ + curl -sL -o /tmp/cpanm https://cpanmin.us/ && \ chmod +x /tmp/cpanm ARG WORK_DIR=/home/netdisco @@ -68,6 +70,7 @@ WORKDIR ${WORK_DIR} # CFLAGS for Authen::TacacsPlus RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ + NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ export PERL5LIB="${WORK_DIR}" \ PERL_CPANM_HOME="${WORK_DIR}/.cpanm" && \ CFLAGS="-Wno-error=old-style-definition -std=gnu17" \ @@ -75,6 +78,7 @@ RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ IO::Tty Authen::TacacsPlus RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ + NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ export PERL5LIB="${WORK_DIR}" \ PERL_CPANM_HOME="${WORK_DIR}/.cpanm" && \ /tmp/cpanm --quiet --notest --local-lib "${WORK_DIR}/perl5" \ @@ -89,6 +93,7 @@ COPY Netdisco.pm /tmp/netdisco-tree/lib/App/Netdisco.pm COPY Builder.pm /tmp/netdisco-tree/lib/App/Netdisco/Builder.pm RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ + NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ export PERL5LIB="${WORK_DIR}" \ PERL_CPANM_HOME="${WORK_DIR}/.cpanm" && \ /tmp/cpanm --quiet --notest --local-lib "${WORK_DIR}/perl5" \ @@ -104,6 +109,7 @@ ARG NETDISCO_GIT_URL=https://github.com/netdisco/netdisco.git ARG COMMITTISH=HEAD RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ + BUILD_DATE= \ export PERL5LIB="${WORK_DIR}" \ PERL_CPANM_HOME="${WORK_DIR}/.cpanm" && \ /tmp/cpanm --quiet --notest --local-lib "${WORK_DIR}/perl5" \ @@ -116,6 +122,7 @@ FROM docker.io/alpine:latest ARG CACHE_BUST_OS=1 RUN --mount=type=cache,target=/var/cache/apk \ + NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ apk update && \ apk add \ shadow \ @@ -146,14 +153,16 @@ RUN --mount=type=cache,target=/var/cache/apk \ icu-data-full \ jq -RUN groupadd -r netdisco -g 901 && \ +RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ + groupadd -r netdisco -g 901 && \ useradd -u 901 -r -p x -g netdisco -m -d /home/netdisco -s /bin/ash -c "netdisco user" netdisco USER netdisco:netdisco -RUN for tgt in bin environments nd-site-local logs; \ +RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ + for tgt in bin environments nd-site-local logs; \ do mkdir /home/netdisco/$tgt; done && \ - ln -s /dev/stdout /home/netdisco/logs/netdisco-backend.log && \ - ln -s /dev/stdout /home/netdisco/logs/netdisco-web.log + ln -s /dev/stdout /home/netdisco/logs/netdisco-backend.log && \ + ln -s /dev/stdout /home/netdisco/logs/netdisco-web.log # copy Netdisco from the bloated build image COPY --chown=netdisco:netdisco --from=netdisco-builder-image \ @@ -163,7 +172,8 @@ COPY --chown=netdisco:netdisco --from=netdisco-builder-image \ COPY --chown=netdisco:netdisco deployment.yml \ /home/netdisco/perl5/lib/perl5/auto/share/dist/App-Netdisco/environments/deployment.yml -RUN for tgt in /home/netdisco/perl5/bin/netdisco-*; \ +RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ + for tgt in /home/netdisco/perl5/bin/netdisco-*; \ do ln -sf $tgt /home/netdisco/bin/; done && \ ln -sf /home/netdisco/perl5/bin/localenv /home/netdisco/bin/ @@ -172,7 +182,8 @@ RUN for tgt in /home/netdisco/perl5/bin/netdisco-*; \ # is added to every container by OpenShift. Harmless when the image runs # as the netdisco user (the default in docker compose). USER root -RUN chgrp -R 0 /home/netdisco && chmod -R g=u /home/netdisco +RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ + chgrp -R 0 /home/netdisco && chmod -R g=u /home/netdisco USER netdisco:netdisco WORKDIR /home/netdisco From 61bc9c99efd7341891ca081c03b820eaca8ece12 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 31 May 2026 20:52:48 +0100 Subject: [PATCH 02/17] remove env set from sh -c --- netdisco-base/Dockerfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/netdisco-base/Dockerfile b/netdisco-base/Dockerfile index 28ef9de..98cd50d 100644 --- a/netdisco-base/Dockerfile +++ b/netdisco-base/Dockerfile @@ -158,11 +158,10 @@ RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ useradd -u 901 -r -p x -g netdisco -m -d /home/netdisco -s /bin/ash -c "netdisco user" netdisco USER netdisco:netdisco -RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ - for tgt in bin environments nd-site-local logs; \ +RUN for tgt in bin environments nd-site-local logs; \ do mkdir /home/netdisco/$tgt; done && \ - ln -s /dev/stdout /home/netdisco/logs/netdisco-backend.log && \ - ln -s /dev/stdout /home/netdisco/logs/netdisco-web.log + ln -s /dev/stdout /home/netdisco/logs/netdisco-backend.log && \ + ln -s /dev/stdout /home/netdisco/logs/netdisco-web.log # copy Netdisco from the bloated build image COPY --chown=netdisco:netdisco --from=netdisco-builder-image \ @@ -172,8 +171,7 @@ COPY --chown=netdisco:netdisco --from=netdisco-builder-image \ COPY --chown=netdisco:netdisco deployment.yml \ /home/netdisco/perl5/lib/perl5/auto/share/dist/App-Netdisco/environments/deployment.yml -RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ - for tgt in /home/netdisco/perl5/bin/netdisco-*; \ +RUN for tgt in /home/netdisco/perl5/bin/netdisco-*; \ do ln -sf $tgt /home/netdisco/bin/; done && \ ln -sf /home/netdisco/perl5/bin/localenv /home/netdisco/bin/ @@ -182,8 +180,7 @@ RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ # is added to every container by OpenShift. Harmless when the image runs # as the netdisco user (the default in docker compose). USER root -RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ - chgrp -R 0 /home/netdisco && chmod -R g=u /home/netdisco +RUN chgrp -R 0 /home/netdisco && chmod -R g=u /home/netdisco USER netdisco:netdisco WORKDIR /home/netdisco From f65d962c2ad2bff98f87a7d0ec04c2dda0ef8f49 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 31 May 2026 21:17:15 +0100 Subject: [PATCH 03/17] Revert "remove env set from sh -c" This reverts commit 61bc9c99efd7341891ca081c03b820eaca8ece12. --- netdisco-base/Dockerfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/netdisco-base/Dockerfile b/netdisco-base/Dockerfile index 98cd50d..28ef9de 100644 --- a/netdisco-base/Dockerfile +++ b/netdisco-base/Dockerfile @@ -158,10 +158,11 @@ RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ useradd -u 901 -r -p x -g netdisco -m -d /home/netdisco -s /bin/ash -c "netdisco user" netdisco USER netdisco:netdisco -RUN for tgt in bin environments nd-site-local logs; \ +RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ + for tgt in bin environments nd-site-local logs; \ do mkdir /home/netdisco/$tgt; done && \ - ln -s /dev/stdout /home/netdisco/logs/netdisco-backend.log && \ - ln -s /dev/stdout /home/netdisco/logs/netdisco-web.log + ln -s /dev/stdout /home/netdisco/logs/netdisco-backend.log && \ + ln -s /dev/stdout /home/netdisco/logs/netdisco-web.log # copy Netdisco from the bloated build image COPY --chown=netdisco:netdisco --from=netdisco-builder-image \ @@ -171,7 +172,8 @@ COPY --chown=netdisco:netdisco --from=netdisco-builder-image \ COPY --chown=netdisco:netdisco deployment.yml \ /home/netdisco/perl5/lib/perl5/auto/share/dist/App-Netdisco/environments/deployment.yml -RUN for tgt in /home/netdisco/perl5/bin/netdisco-*; \ +RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ + for tgt in /home/netdisco/perl5/bin/netdisco-*; \ do ln -sf $tgt /home/netdisco/bin/; done && \ ln -sf /home/netdisco/perl5/bin/localenv /home/netdisco/bin/ @@ -180,7 +182,8 @@ RUN for tgt in /home/netdisco/perl5/bin/netdisco-*; \ # is added to every container by OpenShift. Harmless when the image runs # as the netdisco user (the default in docker compose). USER root -RUN chgrp -R 0 /home/netdisco && chmod -R g=u /home/netdisco +RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ + chgrp -R 0 /home/netdisco && chmod -R g=u /home/netdisco USER netdisco:netdisco WORKDIR /home/netdisco From 087a8d54b5bd7661f75c277d7d30b3cd0892cb21 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 31 May 2026 21:17:23 +0100 Subject: [PATCH 04/17] Revert "try clean env for cache" This reverts commit 34575a4d4b43c2e0d1c52d99d3e44219a29dda98. --- netdisco-backend/Dockerfile | 9 +++------ netdisco-base/Dockerfile | 25 +++++++------------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index 374a403..a03224f 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -5,7 +5,6 @@ FROM localhost:5000/netdisco:${COMMITTISH}-base USER root RUN --mount=type=cache,target=/var/cache/apk \ - COMMITTISH= \ apk add \ ca-certificates \ curl \ @@ -14,8 +13,7 @@ RUN --mount=type=cache,target=/var/cache/apk \ tar WORKDIR /var/lib/postgresql/netdisco-sql -RUN COMMITTISH= \ - curl -sLO "https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql" +RUN curl -sLO "https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql" USER netdisco:netdisco WORKDIR /home/netdisco @@ -25,8 +23,7 @@ WORKDIR /home/netdisco # in which case docker will simply re-download the previous version (the current release) ADD https://github.com/netdisco/netdisco-mibs/raw/refs/heads/master/VERSION /tmp/netdisco-mibs-version -RUN COMMITTISH= \ - curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ +RUN curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ grep browser_download_url | xargs printf "curl -sL %s\n" | tail -1 | \ sh | tar -zxf - @@ -46,7 +43,7 @@ ENV UV_NO_MANAGED_PYTHON=true \ UV_NO_DEV=1 COPY --chown=netdisco:netdisco netdisco-updatedb.sh /home/netdisco/bin/ -RUN COMMITTISH= chmod +x /home/netdisco/bin/netdisco-updatedb.sh +RUN chmod +x /home/netdisco/bin/netdisco-updatedb.sh LABEL org.label-schema.name="netdisco-backend" \ org.label-schema.description="Polling Daemon for Netdisco" diff --git a/netdisco-base/Dockerfile b/netdisco-base/Dockerfile index 28ef9de..83f6393 100644 --- a/netdisco-base/Dockerfile +++ b/netdisco-base/Dockerfile @@ -29,7 +29,6 @@ FROM docker.io/alpine:latest AS netdisco-builder-image ARG CACHE_BUST_OS=1 RUN --mount=type=cache,target=/var/cache/apk \ - NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ apk update && \ apk add \ linux-headers \ @@ -61,8 +60,7 @@ RUN --mount=type=cache,target=/var/cache/apk \ apk fix --no-cache perl perl-dev WORKDIR /tmp -RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ - curl -sL -o /tmp/cpanm https://cpanmin.us/ && \ +RUN curl -sL -o /tmp/cpanm https://cpanmin.us/ && \ chmod +x /tmp/cpanm ARG WORK_DIR=/home/netdisco @@ -70,7 +68,6 @@ WORKDIR ${WORK_DIR} # CFLAGS for Authen::TacacsPlus RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ - NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ export PERL5LIB="${WORK_DIR}" \ PERL_CPANM_HOME="${WORK_DIR}/.cpanm" && \ CFLAGS="-Wno-error=old-style-definition -std=gnu17" \ @@ -78,7 +75,6 @@ RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ IO::Tty Authen::TacacsPlus RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ - NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ export PERL5LIB="${WORK_DIR}" \ PERL_CPANM_HOME="${WORK_DIR}/.cpanm" && \ /tmp/cpanm --quiet --notest --local-lib "${WORK_DIR}/perl5" \ @@ -93,7 +89,6 @@ COPY Netdisco.pm /tmp/netdisco-tree/lib/App/Netdisco.pm COPY Builder.pm /tmp/netdisco-tree/lib/App/Netdisco/Builder.pm RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ - NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ export PERL5LIB="${WORK_DIR}" \ PERL_CPANM_HOME="${WORK_DIR}/.cpanm" && \ /tmp/cpanm --quiet --notest --local-lib "${WORK_DIR}/perl5" \ @@ -109,7 +104,6 @@ ARG NETDISCO_GIT_URL=https://github.com/netdisco/netdisco.git ARG COMMITTISH=HEAD RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ - BUILD_DATE= \ export PERL5LIB="${WORK_DIR}" \ PERL_CPANM_HOME="${WORK_DIR}/.cpanm" && \ /tmp/cpanm --quiet --notest --local-lib "${WORK_DIR}/perl5" \ @@ -122,7 +116,6 @@ FROM docker.io/alpine:latest ARG CACHE_BUST_OS=1 RUN --mount=type=cache,target=/var/cache/apk \ - NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ apk update && \ apk add \ shadow \ @@ -153,16 +146,14 @@ RUN --mount=type=cache,target=/var/cache/apk \ icu-data-full \ jq -RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ - groupadd -r netdisco -g 901 && \ +RUN groupadd -r netdisco -g 901 && \ useradd -u 901 -r -p x -g netdisco -m -d /home/netdisco -s /bin/ash -c "netdisco user" netdisco USER netdisco:netdisco -RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ - for tgt in bin environments nd-site-local logs; \ +RUN for tgt in bin environments nd-site-local logs; \ do mkdir /home/netdisco/$tgt; done && \ - ln -s /dev/stdout /home/netdisco/logs/netdisco-backend.log && \ - ln -s /dev/stdout /home/netdisco/logs/netdisco-web.log + ln -s /dev/stdout /home/netdisco/logs/netdisco-backend.log && \ + ln -s /dev/stdout /home/netdisco/logs/netdisco-web.log # copy Netdisco from the bloated build image COPY --chown=netdisco:netdisco --from=netdisco-builder-image \ @@ -172,8 +163,7 @@ COPY --chown=netdisco:netdisco --from=netdisco-builder-image \ COPY --chown=netdisco:netdisco deployment.yml \ /home/netdisco/perl5/lib/perl5/auto/share/dist/App-Netdisco/environments/deployment.yml -RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ - for tgt in /home/netdisco/perl5/bin/netdisco-*; \ +RUN for tgt in /home/netdisco/perl5/bin/netdisco-*; \ do ln -sf $tgt /home/netdisco/bin/; done && \ ln -sf /home/netdisco/perl5/bin/localenv /home/netdisco/bin/ @@ -182,8 +172,7 @@ RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ # is added to every container by OpenShift. Harmless when the image runs # as the netdisco user (the default in docker compose). USER root -RUN NETDISCO_GIT_URL= COMMITTISH= BUILD_DATE= \ - chgrp -R 0 /home/netdisco && chmod -R g=u /home/netdisco +RUN chgrp -R 0 /home/netdisco && chmod -R g=u /home/netdisco USER netdisco:netdisco WORKDIR /home/netdisco From 340ba9ebe03213960b0064227a7435f4cfd9341a Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 31 May 2026 21:43:23 +0100 Subject: [PATCH 05/17] reorder base dockerfile and move labels to prod images --- docker-bake.hcl | 1 - netdisco-backend/Dockerfile | 15 ++++++-- netdisco-base/Dockerfile | 69 +++++++++++++++---------------------- netdisco-web/Dockerfile | 15 ++++++-- 4 files changed, 54 insertions(+), 46 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 4bee308..e4e0a74 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -31,7 +31,6 @@ target "netdisco-base" { args = { COMMITTISH = COMMITTISH NETDISCO_GIT_URL = NETDISCO_GIT_URL - BUILD_DATE = BUILD_DATE } output = ["type=docker"] } diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index a03224f..9f5bcc4 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -45,8 +45,19 @@ ENV UV_NO_MANAGED_PYTHON=true \ COPY --chown=netdisco:netdisco netdisco-updatedb.sh /home/netdisco/bin/ RUN chmod +x /home/netdisco/bin/netdisco-updatedb.sh -LABEL org.label-schema.name="netdisco-backend" \ - org.label-schema.description="Polling Daemon for Netdisco" +ARG BUILD_DATE +LABEL org.label-schema.docker.schema-version="1.0" \ + org.label-schema.vendor="The Netdisco Project" \ + org.label-schema.url="http://netdisco.org" \ + org.label-schema.name="netdisco-backend" \ + org.label-schema.description="Polling Daemon for Netdisco" \ + org.label-schema.usage="https://github.com/netdisco/netdisco-docker/blob/master/README.md" \ + org.label-schema.version=${COMMITTISH} \ + org.label-schema.vcs-ref=${COMMITTISH} \ + org.label-schema.vcs-url="git://github.com/netdisco/netdisco.git" \ + org.label-schema.build-date=${BUILD_DATE} \ + org.netdisco.maintainer="The Netdisco Project" \ + org.netdisco.version=${COMMITTISH} ENTRYPOINT ["/home/netdisco/bin/netdisco-backend"] CMD ["foreground"] diff --git a/netdisco-base/Dockerfile b/netdisco-base/Dockerfile index 83f6393..210a48e 100644 --- a/netdisco-base/Dockerfile +++ b/netdisco-base/Dockerfile @@ -1,28 +1,6 @@ # vim: ft=Dockerfile # ---------------------------------------------------------------------------- -FROM docker.io/alpine:latest AS fetcher - -# retrieve Build.PL to use as a cache invalidation test (whether to rebuild -# netdisco dependencies which is a very slow task) - -RUN --mount=type=cache,target=/var/cache/apk \ - apk add git - -# NETDISCO_GIT_URL lets CI / local builds point at a fork (e.g. to test a PR) -# without editing the Dockerfile. Defaults to upstream. - -ARG NETDISCO_GIT_URL=https://github.com/netdisco/netdisco.git -ARG COMMITTISH=HEAD - -WORKDIR /fetch - -RUN git init \ - && git remote add origin "${NETDISCO_GIT_URL}" \ - && git fetch --depth 1 origin "${COMMITTISH}" \ - && git reset --hard FETCH_HEAD - -# ---------------------------------------------------------------------------- -FROM docker.io/alpine:latest AS netdisco-builder-image +FROM docker.io/alpine:latest AS netdisco-static-image # temporary bloated image used for building Netdisco. # netdisco-base will copy the built Netdisco files from this image @@ -82,7 +60,32 @@ RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ URL::Encode \ REST::Client -# grab the fetched file from the first stage. +# ---------------------------------------------------------------------------- +FROM docker.io/alpine:latest AS fetcher + +# retrieve Build.PL to use as a cache invalidation test (whether to rebuild +# netdisco dependencies which is a very slow task) + +RUN --mount=type=cache,target=/var/cache/apk \ + apk add git + +# NETDISCO_GIT_URL lets CI / local builds point at a fork (e.g. to test a PR) +# without editing the Dockerfile. Defaults to upstream. + +ARG NETDISCO_GIT_URL=https://github.com/netdisco/netdisco.git +ARG COMMITTISH=HEAD + +WORKDIR /fetch + +RUN git init \ + && git remote add origin "${NETDISCO_GIT_URL}" \ + && git fetch --depth 1 origin "${COMMITTISH}" \ + && git reset --hard FETCH_HEAD + +# ---------------------------------------------------------------------------- +FROM netdisco-static-image AS netdisco-builder-image + +# grab the fetched file from the second stage. # if Build.PL has not changed, Docker's cache remains valid. COPY --from=fetcher /fetch/Build.PL /tmp/netdisco-tree/Build.PL COPY Netdisco.pm /tmp/netdisco-tree/lib/App/Netdisco.pm @@ -180,23 +183,7 @@ WORKDIR /home/netdisco ENV PATH="/home/netdisco/bin:$PATH" ENV SHELL=/bin/ash -ARG BUILD_DATE -ARG COMMITTISH=HEAD - -LABEL org.label-schema.docker.schema-version="1.0" \ - org.label-schema.vendor="The Netdisco Project" \ - org.label-schema.url="http://netdisco.org" \ - org.label-schema.name="Netdisco Base" \ - org.label-schema.description="Base Image for Netdisco" \ - org.label-schema.usage="https://github.com/netdisco/netdisco-docker/blob/master/README.md" \ - org.label-schema.version=${COMMITTISH} \ - org.label-schema.vcs-ref=${COMMITTISH} \ - org.label-schema.vcs-url="git://github.com/netdisco/netdisco.git" \ - org.label-schema.build-date=${BUILD_DATE} \ - org.netdisco.maintainer="The Netdisco Project" \ - org.netdisco.version=${COMMITTISH} - - ## volumes can be optional, and controlled by docker-compose file +## volumes can be optional, and controlled by docker-compose file # VOLUME ["/home/netdisco/environments", "/home/netdisco/nd-site-local", "/home/netdisco/logs"] CMD ["ash"] diff --git a/netdisco-web/Dockerfile b/netdisco-web/Dockerfile index 8d2c50d..c899926 100644 --- a/netdisco-web/Dockerfile +++ b/netdisco-web/Dockerfile @@ -2,8 +2,19 @@ ARG COMMITTISH=latest FROM localhost:5000/netdisco:${COMMITTISH}-base -LABEL org.label-schema.name="netdisco-web" \ - org.label-schema.description="Web Frontend for Netdisco" +ARG BUILD_DATE +LABEL org.label-schema.docker.schema-version="1.0" \ + org.label-schema.vendor="The Netdisco Project" \ + org.label-schema.url="http://netdisco.org" \ + org.label-schema.name="netdisco-web" \ + org.label-schema.description="Web Frontend for Netdisco" \ + org.label-schema.usage="https://github.com/netdisco/netdisco-docker/blob/master/README.md" \ + org.label-schema.version=${COMMITTISH} \ + org.label-schema.vcs-ref=${COMMITTISH} \ + org.label-schema.vcs-url="git://github.com/netdisco/netdisco.git" \ + org.label-schema.build-date=${BUILD_DATE} \ + org.netdisco.maintainer="The Netdisco Project" \ + org.netdisco.version=${COMMITTISH} EXPOSE 5000 ENTRYPOINT ["/home/netdisco/bin/netdisco-web"] From 491afebdb0095a787ec15e9fa40638ac0172f6eb Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 1 Jun 2026 07:00:59 +0100 Subject: [PATCH 06/17] add BUILD_DATE back for web and backend --- docker-bake.hcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-bake.hcl b/docker-bake.hcl index e4e0a74..d5d02ec 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -43,6 +43,7 @@ target "netdisco-web" { ] args = { COMMITTISH = COMMITTISH + BUILD_DATE = BUILD_DATE } contexts = { "localhost:5000/netdisco:${COMMITTISH}-base" = "target:netdisco-base" @@ -58,6 +59,7 @@ target "netdisco-backend" { ] args = { COMMITTISH = COMMITTISH + BUILD_DATE = BUILD_DATE } contexts = { "localhost:5000/netdisco:${COMMITTISH}-base" = "target:netdisco-base" From 134e4935ab7a0dd36c2eca8e9443a4bc6bd936db Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 1 Jun 2026 18:40:27 +0100 Subject: [PATCH 07/17] change default COMMITTISH to HEAD --- netdisco-backend/Dockerfile | 4 +--- netdisco-base/Dockerfile | 4 ++-- netdisco-web/Dockerfile | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index 9f5bcc4..11b6d24 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -1,9 +1,8 @@ # vim: ft=Dockerfile -ARG COMMITTISH=latest +ARG COMMITTISH=HEAD FROM localhost:5000/netdisco:${COMMITTISH}-base USER root - RUN --mount=type=cache,target=/var/cache/apk \ apk add \ ca-certificates \ @@ -27,7 +26,6 @@ RUN curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest grep browser_download_url | xargs printf "curl -sL %s\n" | tail -1 | \ sh | tar -zxf - -ARG COMMITTISH=HEAD RUN rm -f /home/netdisco/perl5/lib/perl5/auto/share/dist/App-Netdisco/python/netdisco/uv.lock RUN `/home/netdisco/bin/localenv perl -MAlien::ultraviolet -e 'print Alien::ultraviolet->uv'` \ --no-cache --no-progress --quiet --project \ diff --git a/netdisco-base/Dockerfile b/netdisco-base/Dockerfile index 210a48e..0c90ff5 100644 --- a/netdisco-base/Dockerfile +++ b/netdisco-base/Dockerfile @@ -69,14 +69,14 @@ FROM docker.io/alpine:latest AS fetcher RUN --mount=type=cache,target=/var/cache/apk \ apk add git +WORKDIR /fetch + # NETDISCO_GIT_URL lets CI / local builds point at a fork (e.g. to test a PR) # without editing the Dockerfile. Defaults to upstream. ARG NETDISCO_GIT_URL=https://github.com/netdisco/netdisco.git ARG COMMITTISH=HEAD -WORKDIR /fetch - RUN git init \ && git remote add origin "${NETDISCO_GIT_URL}" \ && git fetch --depth 1 origin "${COMMITTISH}" \ diff --git a/netdisco-web/Dockerfile b/netdisco-web/Dockerfile index c899926..97b4670 100644 --- a/netdisco-web/Dockerfile +++ b/netdisco-web/Dockerfile @@ -1,5 +1,5 @@ # vim: ft=Dockerfile -ARG COMMITTISH=latest +ARG COMMITTISH=HEAD FROM localhost:5000/netdisco:${COMMITTISH}-base ARG BUILD_DATE From ed34a6dd0c27bb12cbd5dba6bcb2369a0ebcad86 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 1 Jun 2026 18:54:14 +0100 Subject: [PATCH 08/17] clean the hcl file --- docker-bake.hcl | 60 ++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index d5d02ec..a41dd83 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -3,7 +3,7 @@ variable "NETDISCO_GIT_URL" { } variable "COMMITTISH" { - default = "latest" + default = "HEAD" } variable "BUILD_DATE" { @@ -23,44 +23,32 @@ group "all" { } target "netdisco-base" { - context = "./netdisco-base" - dockerfile = "Dockerfile" - tags = [ - "localhost:5000/netdisco:${COMMITTISH}-base", - ] + name = "netdisco-base" + context = "./netdisco-base" args = { COMMITTISH = COMMITTISH NETDISCO_GIT_URL = NETDISCO_GIT_URL } - output = ["type=docker"] -} - -target "netdisco-web" { - context = "./netdisco-web" - dockerfile = "Dockerfile" tags = [ - "localhost:5000/netdisco:${COMMITTISH}-web", + "localhost:5000/netdisco:${COMMITTISH}-base", ] - args = { - COMMITTISH = COMMITTISH - BUILD_DATE = BUILD_DATE - } - contexts = { - "localhost:5000/netdisco:${COMMITTISH}-base" = "target:netdisco-base" - } output = ["type=docker"] } -target "netdisco-backend" { - context = "./netdisco-backend" - dockerfile = "Dockerfile" - tags = [ - "localhost:5000/netdisco:${COMMITTISH}-backend", - ] +target "netdisco" { + name = "netdisco-${tgt}" + matrix = { + tgt = ["backend", "web"] + } + target = tgt + context = "./netdisco-${tgt}" args = { COMMITTISH = COMMITTISH BUILD_DATE = BUILD_DATE } + tags = [ + "localhost:5000/netdisco:${COMMITTISH}-${tgt}", + ] contexts = { "localhost:5000/netdisco:${COMMITTISH}-base" = "target:netdisco-base" } @@ -68,28 +56,28 @@ target "netdisco-backend" { } target "netdisco-postgresql" { - context = "./netdisco-postgresql" - dockerfile = "Dockerfile" - tags = [ - "localhost:5000/netdisco:${COMMITTISH}-postgresql", - ] + name = "netdisco-postgresql" + context = "./netdisco-postgresql" args = { COMMITTISH = COMMITTISH BUILD_DATE = BUILD_DATE } + tags = [ + "localhost:5000/netdisco:${COMMITTISH}-postgresql", + ] output = ["type=docker"] } target "netdisco-postgresql-13" { - context = "./netdisco-postgresql" - dockerfile = "Dockerfile" - tags = [ - "localhost:5000/netdisco:${COMMITTISH}-postgresql-13", - ] + name = "netdisco-postgresql-13" + context = "./netdisco-postgresql" args = { PGVER = "13.4" COMMITTISH = COMMITTISH BUILD_DATE = BUILD_DATE } + tags = [ + "localhost:5000/netdisco:${COMMITTISH}-postgresql-13", + ] output = ["type=docker"] } From 338863b413e40f3f3e93525ae8fbe539a7a2d8e4 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 1 Jun 2026 18:55:42 +0100 Subject: [PATCH 09/17] fix error missing arg --- netdisco-backend/Dockerfile | 2 ++ netdisco-web/Dockerfile | 2 ++ 2 files changed, 4 insertions(+) diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index 11b6d24..88d2424 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -43,7 +43,9 @@ ENV UV_NO_MANAGED_PYTHON=true \ COPY --chown=netdisco:netdisco netdisco-updatedb.sh /home/netdisco/bin/ RUN chmod +x /home/netdisco/bin/netdisco-updatedb.sh +ARG COMMITTISH=HEAD ARG BUILD_DATE + LABEL org.label-schema.docker.schema-version="1.0" \ org.label-schema.vendor="The Netdisco Project" \ org.label-schema.url="http://netdisco.org" \ diff --git a/netdisco-web/Dockerfile b/netdisco-web/Dockerfile index 97b4670..5db6271 100644 --- a/netdisco-web/Dockerfile +++ b/netdisco-web/Dockerfile @@ -2,7 +2,9 @@ ARG COMMITTISH=HEAD FROM localhost:5000/netdisco:${COMMITTISH}-base +ARG COMMITTISH=HEAD ARG BUILD_DATE + LABEL org.label-schema.docker.schema-version="1.0" \ org.label-schema.vendor="The Netdisco Project" \ org.label-schema.url="http://netdisco.org" \ From d5420109c474905143b6073232d05830f4e566ea Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 2 Jun 2026 10:45:19 +0100 Subject: [PATCH 10/17] refactor HCL to use matrix and Dockerfiles to use layered packages and ADD command for SQL --- docker-bake.hcl | 5 +- netdisco-backend/Dockerfile | 19 ++---- netdisco-base/Dockerfile | 122 +++++++++++++++++------------------- netdisco-web/Dockerfile | 3 +- 4 files changed, 64 insertions(+), 85 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index a41dd83..282fe2f 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -23,14 +23,13 @@ group "all" { } target "netdisco-base" { - name = "netdisco-base" context = "./netdisco-base" args = { COMMITTISH = COMMITTISH NETDISCO_GIT_URL = NETDISCO_GIT_URL } tags = [ - "localhost:5000/netdisco:${COMMITTISH}-base", + "localhost:5000/netdisco:builder-base", ] output = ["type=docker"] } @@ -56,7 +55,6 @@ target "netdisco" { } target "netdisco-postgresql" { - name = "netdisco-postgresql" context = "./netdisco-postgresql" args = { COMMITTISH = COMMITTISH @@ -69,7 +67,6 @@ target "netdisco-postgresql" { } target "netdisco-postgresql-13" { - name = "netdisco-postgresql-13" context = "./netdisco-postgresql" args = { PGVER = "13.4" diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index 88d2424..bc573c7 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -1,18 +1,5 @@ # vim: ft=Dockerfile -ARG COMMITTISH=HEAD -FROM localhost:5000/netdisco:${COMMITTISH}-base - -USER root -RUN --mount=type=cache,target=/var/cache/apk \ - apk add \ - ca-certificates \ - curl \ - openssh-client \ - bash \ - tar - -WORKDIR /var/lib/postgresql/netdisco-sql -RUN curl -sLO "https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql" +FROM localhost:5000/netdisco:builder-base USER netdisco:netdisco WORKDIR /home/netdisco @@ -26,6 +13,10 @@ RUN curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest grep browser_download_url | xargs printf "curl -sL %s\n" | tail -1 | \ sh | tar -zxf - +# this will probably bust the cache as it updates weekly +# but that's OK, the rest of this Dockerfile we want to rebuild fresh +ADD --chown=root:root https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql /var/lib/postgresql/netdisco-sql/ + RUN rm -f /home/netdisco/perl5/lib/perl5/auto/share/dist/App-Netdisco/python/netdisco/uv.lock RUN `/home/netdisco/bin/localenv perl -MAlien::ultraviolet -e 'print Alien::ultraviolet->uv'` \ --no-cache --no-progress --quiet --project \ diff --git a/netdisco-base/Dockerfile b/netdisco-base/Dockerfile index 0c90ff5..03ea34d 100644 --- a/netdisco-base/Dockerfile +++ b/netdisco-base/Dockerfile @@ -1,6 +1,28 @@ # vim: ft=Dockerfile # ---------------------------------------------------------------------------- -FROM docker.io/alpine:latest AS netdisco-static-image +FROM docker.io/alpine:latest AS fetcher + +# retrieve Build.PL to use as a cache invalidation test (whether to rebuild +# netdisco dependencies which is a very slow task) + +RUN --mount=type=cache,target=/var/cache/apk \ + apk add git + +WORKDIR /fetch + +# NETDISCO_GIT_URL lets CI / local builds point at a fork (e.g. to test a PR) +# without editing the Dockerfile. Defaults to upstream. + +ARG NETDISCO_GIT_URL=https://github.com/netdisco/netdisco.git +ARG COMMITTISH=HEAD + +RUN git init \ + && git remote add origin "${NETDISCO_GIT_URL}" \ + && git fetch --depth 1 origin "${COMMITTISH}" \ + && git reset --hard FETCH_HEAD + +# ---------------------------------------------------------------------------- +FROM docker.io/alpine:latest AS netdisco-common-base # temporary bloated image used for building Netdisco. # netdisco-base will copy the built Netdisco files from this image @@ -9,31 +31,55 @@ ARG CACHE_BUST_OS=1 RUN --mount=type=cache,target=/var/cache/apk \ apk update && \ apk add \ - linux-headers \ + bash \ ca-certificates \ curl \ + expect \ + expect-dev \ findutils \ - g++ \ - gcc \ - git \ + icu-data-full \ jq \ libc6-compat \ musl-dev \ musl-obstack-dev \ - make \ net-snmp-perl \ - openssl-dev \ + openssh-client \ perl-crypt-rijndael \ perl-dbd-pg \ - perl-dev \ + perl-file-sharedir \ + perl-file-slurp \ perl-io-socket-ssl \ + perl-json \ perl-ldap \ + perl-lwp-protocol-https \ perl-netaddr-ip \ + perl-regexp-common \ + perl-regexp-common-net-cidr \ + perl-regexp-ipv6 \ postgresql18-client \ - postgresql18-dev \ python3 \ + shadow \ + tar \ tzdata \ - openssh-client \ + zstd && \ + apk fix --no-cache perl perl-dev + +# ---------------------------------------------------------------------------- +FROM netdisco-common-base AS netdisco-builder-image + +# temporary bloated image used for building Netdisco. +# netdisco-base will copy the built Netdisco files from this image + +RUN --mount=type=cache,target=/var/cache/apk \ + apk add \ + g++ \ + gcc \ + git \ + linux-headers \ + make \ + openssl-dev \ + perl-dev \ + postgresql18-dev \ wget && \ apk fix --no-cache perl perl-dev @@ -60,31 +106,6 @@ RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ URL::Encode \ REST::Client -# ---------------------------------------------------------------------------- -FROM docker.io/alpine:latest AS fetcher - -# retrieve Build.PL to use as a cache invalidation test (whether to rebuild -# netdisco dependencies which is a very slow task) - -RUN --mount=type=cache,target=/var/cache/apk \ - apk add git - -WORKDIR /fetch - -# NETDISCO_GIT_URL lets CI / local builds point at a fork (e.g. to test a PR) -# without editing the Dockerfile. Defaults to upstream. - -ARG NETDISCO_GIT_URL=https://github.com/netdisco/netdisco.git -ARG COMMITTISH=HEAD - -RUN git init \ - && git remote add origin "${NETDISCO_GIT_URL}" \ - && git fetch --depth 1 origin "${COMMITTISH}" \ - && git reset --hard FETCH_HEAD - -# ---------------------------------------------------------------------------- -FROM netdisco-static-image AS netdisco-builder-image - # grab the fetched file from the second stage. # if Build.PL has not changed, Docker's cache remains valid. COPY --from=fetcher /fetch/Build.PL /tmp/netdisco-tree/Build.PL @@ -115,39 +136,10 @@ RUN --mount=type=cache,target=${WORK_DIR}/.cpanm,sharing=locked \ RUN mv /home/netdisco /home/netdisco-build # ---------------------------------------------------------------------------- -FROM docker.io/alpine:latest +FROM netdisco-common-base -ARG CACHE_BUST_OS=1 RUN --mount=type=cache,target=/var/cache/apk \ - apk update && \ apk add \ - shadow \ - findutils \ - libc6-compat \ - musl-dev \ - musl-obstack-dev \ - net-snmp-perl \ - expect \ - expect-dev \ - perl-crypt-rijndael \ - perl-dbd-pg \ - perl-io-socket-ssl \ - perl-ldap \ - perl-json \ - perl-lwp-protocol-https \ - perl-file-slurp \ - perl-regexp-common \ - perl-regexp-common-net-cidr \ - perl-regexp-ipv6 \ - perl-file-sharedir \ - perl-netaddr-ip \ - postgresql18-client \ - python3 \ - tzdata \ - bash \ - zstd \ - icu-data-full \ - jq RUN groupadd -r netdisco -g 901 && \ useradd -u 901 -r -p x -g netdisco -m -d /home/netdisco -s /bin/ash -c "netdisco user" netdisco diff --git a/netdisco-web/Dockerfile b/netdisco-web/Dockerfile index 5db6271..f9ecf2f 100644 --- a/netdisco-web/Dockerfile +++ b/netdisco-web/Dockerfile @@ -1,6 +1,5 @@ # vim: ft=Dockerfile -ARG COMMITTISH=HEAD -FROM localhost:5000/netdisco:${COMMITTISH}-base +FROM localhost:5000/netdisco:builder-base ARG COMMITTISH=HEAD ARG BUILD_DATE From 1c03d34b8df5aa11668a57a01ff3cef6d3f7989a Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 2 Jun 2026 10:48:52 +0100 Subject: [PATCH 11/17] fix hcl error --- docker-bake.hcl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 282fe2f..3b34977 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -11,15 +11,15 @@ variable "BUILD_DATE" { } group "default" { - targets = ["netdisco-backend","netdisco-web"] + targets = ["netdisco"] } group "standalone" { - targets = ["netdisco-postgresql","netdisco-backend", "netdisco-web"] + targets = ["netdisco-postgresql","netdisco"] } group "all" { - targets = ["netdisco-postgresql","netdisco-postgresql-13","netdisco-backend", "netdisco-web"] + targets = ["netdisco-postgresql","netdisco-postgresql-13","netdisco"] } target "netdisco-base" { From 9ddea292c9c6e2fd1d79d30d7f006e10dbead60b Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 2 Jun 2026 10:57:56 +0100 Subject: [PATCH 12/17] other fixes to HCL and Dockerfile --- docker-bake.hcl | 6 +++--- netdisco-backend/Dockerfile | 2 +- netdisco-base/Dockerfile | 3 --- netdisco-web/Dockerfile | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 3b34977..f7190d8 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -29,7 +29,7 @@ target "netdisco-base" { NETDISCO_GIT_URL = NETDISCO_GIT_URL } tags = [ - "localhost:5000/netdisco:builder-base", + "localhost:5000/netdisco:netdisco-base", ] output = ["type=docker"] } @@ -39,7 +39,7 @@ target "netdisco" { matrix = { tgt = ["backend", "web"] } - target = tgt +# target = "netdisco-${tgt}" context = "./netdisco-${tgt}" args = { COMMITTISH = COMMITTISH @@ -49,7 +49,7 @@ target "netdisco" { "localhost:5000/netdisco:${COMMITTISH}-${tgt}", ] contexts = { - "localhost:5000/netdisco:${COMMITTISH}-base" = "target:netdisco-base" + "localhost:5000/netdisco:netdisco-base" = "target:netdisco-base" } output = ["type=docker"] } diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index bc573c7..cc8b049 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -1,5 +1,5 @@ # vim: ft=Dockerfile -FROM localhost:5000/netdisco:builder-base +FROM localhost:5000/netdisco:netdisco-base USER netdisco:netdisco WORKDIR /home/netdisco diff --git a/netdisco-base/Dockerfile b/netdisco-base/Dockerfile index 03ea34d..8afc78b 100644 --- a/netdisco-base/Dockerfile +++ b/netdisco-base/Dockerfile @@ -138,9 +138,6 @@ RUN mv /home/netdisco /home/netdisco-build # ---------------------------------------------------------------------------- FROM netdisco-common-base -RUN --mount=type=cache,target=/var/cache/apk \ - apk add \ - RUN groupadd -r netdisco -g 901 && \ useradd -u 901 -r -p x -g netdisco -m -d /home/netdisco -s /bin/ash -c "netdisco user" netdisco USER netdisco:netdisco diff --git a/netdisco-web/Dockerfile b/netdisco-web/Dockerfile index f9ecf2f..c414415 100644 --- a/netdisco-web/Dockerfile +++ b/netdisco-web/Dockerfile @@ -1,5 +1,5 @@ # vim: ft=Dockerfile -FROM localhost:5000/netdisco:builder-base +FROM localhost:5000/netdisco:netdisco-base ARG COMMITTISH=HEAD ARG BUILD_DATE From 68f878ce47bf739772d19a431be3a24c7e19b2f8 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 2 Jun 2026 11:35:28 +0100 Subject: [PATCH 13/17] try to fix run curl --- netdisco-backend/Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index cc8b049..492f57f 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -2,16 +2,16 @@ FROM localhost:5000/netdisco:netdisco-base USER netdisco:netdisco -WORKDIR /home/netdisco # if Netdisco MIBs VERSION has not changed, Docker's cache remains valid. # there is a slight race, when the VERSION could have been updated in the repo before a release is made # in which case docker will simply re-download the previous version (the current release) ADD https://github.com/netdisco/netdisco-mibs/raw/refs/heads/master/VERSION /tmp/netdisco-mibs-version -RUN curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ +WORKDIR /home/netdisco/netdisco-mibs +RUN 'curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ grep browser_download_url | xargs printf "curl -sL %s\n" | tail -1 | \ - sh | tar -zxf - + sh | tar --strip-components=1 -zxf -' # this will probably bust the cache as it updates weekly # but that's OK, the rest of this Dockerfile we want to rebuild fresh @@ -50,5 +50,6 @@ LABEL org.label-schema.docker.schema-version="1.0" \ org.netdisco.maintainer="The Netdisco Project" \ org.netdisco.version=${COMMITTISH} +WORKDIR /home/netdisco ENTRYPOINT ["/home/netdisco/bin/netdisco-backend"] CMD ["foreground"] From b4e4f403be36c1538cd6956c7cddafccdd36a6ff Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 2 Jun 2026 12:14:44 +0100 Subject: [PATCH 14/17] try different shelling --- netdisco-backend/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index 492f57f..d4a076f 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -9,8 +9,8 @@ USER netdisco:netdisco ADD https://github.com/netdisco/netdisco-mibs/raw/refs/heads/master/VERSION /tmp/netdisco-mibs-version WORKDIR /home/netdisco/netdisco-mibs -RUN 'curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ - grep browser_download_url | xargs printf "curl -sL %s\n" | tail -1 | \ +RUN '/usr/bin/curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ + grep browser_download_url | xargs printf "/usr/bin/curl -sL %s\n" | tail -1 | \ sh | tar --strip-components=1 -zxf -' # this will probably bust the cache as it updates weekly From 87d3b69e8227045684f19ffff414319ea3c809da Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 2 Jun 2026 16:09:37 +0100 Subject: [PATCH 15/17] try different shell escape --- netdisco-backend/Dockerfile | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index d4a076f..3e982dc 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -1,21 +1,28 @@ # vim: ft=Dockerfile -FROM localhost:5000/netdisco:netdisco-base - -USER netdisco:netdisco +# ---------------------------------------------------------------------------- +FROM docker.io/alpine:latest AS netdisco-mibs # if Netdisco MIBs VERSION has not changed, Docker's cache remains valid. # there is a slight race, when the VERSION could have been updated in the repo before a release is made # in which case docker will simply re-download the previous version (the current release) ADD https://github.com/netdisco/netdisco-mibs/raw/refs/heads/master/VERSION /tmp/netdisco-mibs-version -WORKDIR /home/netdisco/netdisco-mibs -RUN '/usr/bin/curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ +WORKDIR /tmp/netdisco-mibs +RUN `/usr/bin/curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/releases/latest | \ grep browser_download_url | xargs printf "/usr/bin/curl -sL %s\n" | tail -1 | \ - sh | tar --strip-components=1 -zxf -' + sh | tar --strip-components=1 -zxf -` + +# ---------------------------------------------------------------------------- +FROM docker.io/alpine:latest AS netdisco-sql # this will probably bust the cache as it updates weekly -# but that's OK, the rest of this Dockerfile we want to rebuild fresh -ADD --chown=root:root https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql /var/lib/postgresql/netdisco-sql/ +ADD https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql /tmp/ + +# ---------------------------------------------------------------------------- +FROM localhost:5000/netdisco:netdisco-base + +USER netdisco:netdisco +WORKDIR /home/netdisco RUN rm -f /home/netdisco/perl5/lib/perl5/auto/share/dist/App-Netdisco/python/netdisco/uv.lock RUN `/home/netdisco/bin/localenv perl -MAlien::ultraviolet -e 'print Alien::ultraviolet->uv'` \ @@ -31,8 +38,9 @@ ENV UV_NO_MANAGED_PYTHON=true \ UV_NO_CACHE=1 \ UV_NO_DEV=1 -COPY --chown=netdisco:netdisco netdisco-updatedb.sh /home/netdisco/bin/ -RUN chmod +x /home/netdisco/bin/netdisco-updatedb.sh +COPY --chown=netdisco:netdisco --chmod=755 netdisco-updatedb.sh /home/netdisco/bin/ +COPY --from=netdisco-mibs --chown=netdisco:netdisco /tmp/netdisco-mibs /home/netdisco/ +COPY --from=netdisco-sql --chown=root:root /tmp/netdisco-lookup-tables.sql /var/lib/postgresql/netdisco-sql/ ARG COMMITTISH=HEAD ARG BUILD_DATE @@ -50,6 +58,5 @@ LABEL org.label-schema.docker.schema-version="1.0" \ org.netdisco.maintainer="The Netdisco Project" \ org.netdisco.version=${COMMITTISH} -WORKDIR /home/netdisco ENTRYPOINT ["/home/netdisco/bin/netdisco-backend"] CMD ["foreground"] From 1660068270bf1867ac3dc743e583c35832142618 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 2 Jun 2026 16:12:12 +0100 Subject: [PATCH 16/17] add curl --- netdisco-backend/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index 3e982dc..a20a82f 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -2,6 +2,9 @@ # ---------------------------------------------------------------------------- FROM docker.io/alpine:latest AS netdisco-mibs +RUN --mount=type=cache,target=/var/cache/apk \ + apk add curl + # if Netdisco MIBs VERSION has not changed, Docker's cache remains valid. # there is a slight race, when the VERSION could have been updated in the repo before a release is made # in which case docker will simply re-download the previous version (the current release) From bb58742999e70d933bddeee2758686b6d2433206 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 3 Jun 2026 05:30:16 +0100 Subject: [PATCH 17/17] restore dynamic base image with committish --- docker-bake.hcl | 5 ++--- netdisco-backend/Dockerfile | 3 ++- netdisco-web/Dockerfile | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index f7190d8..30b96c1 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -29,7 +29,7 @@ target "netdisco-base" { NETDISCO_GIT_URL = NETDISCO_GIT_URL } tags = [ - "localhost:5000/netdisco:netdisco-base", + "localhost:5000/netdisco:${COMMITTISH}-base", ] output = ["type=docker"] } @@ -39,7 +39,6 @@ target "netdisco" { matrix = { tgt = ["backend", "web"] } -# target = "netdisco-${tgt}" context = "./netdisco-${tgt}" args = { COMMITTISH = COMMITTISH @@ -49,7 +48,7 @@ target "netdisco" { "localhost:5000/netdisco:${COMMITTISH}-${tgt}", ] contexts = { - "localhost:5000/netdisco:netdisco-base" = "target:netdisco-base" + "localhost:5000/netdisco:${COMMITTISH}-base" = "target:netdisco-base" } output = ["type=docker"] } diff --git a/netdisco-backend/Dockerfile b/netdisco-backend/Dockerfile index a20a82f..aeef1ea 100644 --- a/netdisco-backend/Dockerfile +++ b/netdisco-backend/Dockerfile @@ -1,4 +1,5 @@ # vim: ft=Dockerfile +ARG COMMITTISH=HEAD # ---------------------------------------------------------------------------- FROM docker.io/alpine:latest AS netdisco-mibs @@ -22,7 +23,7 @@ FROM docker.io/alpine:latest AS netdisco-sql ADD https://github.com/netdisco/upstream-sources/raw/refs/heads/master/bootstrap/netdisco-lookup-tables.sql /tmp/ # ---------------------------------------------------------------------------- -FROM localhost:5000/netdisco:netdisco-base +FROM localhost:5000/netdisco:${COMMITTISH}-base USER netdisco:netdisco WORKDIR /home/netdisco diff --git a/netdisco-web/Dockerfile b/netdisco-web/Dockerfile index c414415..5db6271 100644 --- a/netdisco-web/Dockerfile +++ b/netdisco-web/Dockerfile @@ -1,5 +1,6 @@ # vim: ft=Dockerfile -FROM localhost:5000/netdisco:netdisco-base +ARG COMMITTISH=HEAD +FROM localhost:5000/netdisco:${COMMITTISH}-base ARG COMMITTISH=HEAD ARG BUILD_DATE