From bca49e50319b9818ce53092f64b1bf7b9ddd7223 Mon Sep 17 00:00:00 2001 From: Mike Kolesnik Date: Mon, 11 Dec 2023 14:52:41 +0200 Subject: [PATCH] Make Shipyard's location dynamic For easier consumption from other projects, and for easier POCs, make the URL and image locations dynamic so that we can specify where to take base Shipyard files and images from. Signed-off-by: Mike Kolesnik --- .dapper | 9 ++++----- Dockerfile.dapper | 5 +++-- Dockerfile.linting | 5 +++-- Makefile.dapper | 7 ++++--- Makefile.dapper.base | 4 ++-- README.md | 6 +++--- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.dapper b/.dapper index b7f5cbabc..345969ade 100755 --- a/.dapper +++ b/.dapper @@ -69,14 +69,13 @@ done [ -n "$command" ] && set -- "$command" +buildargs=(--build-arg "ORG=${ORG}" --build-arg "PROJECT=${PROJECT}") +[ -n "${SHIPYARD_REPO}" ] && buildargs+=(--build-arg "SHIPYARD_REPO=${SHIPYARD_REPO}") +[ -n "${SHIPYARD_TAG}" ] && buildargs+=(--build-arg "SHIPYARD_TAG=${SHIPYARD_TAG}") gitid="$(git symbolic-ref --short HEAD 2>/dev/null | tr / _ || :)" gitid="${gitid:-$(git show --format=%h -s)}" container="$(basename "$(pwd)"):${gitid}" -DOCKER_BUILDKIT=1 docker build -t "${container}" -f "${file}" \ - --build-arg "BASE_BRANCH=${BASE_BRANCH:-devel}" \ - --build-arg "ORG=${ORG}" \ - --build-arg "PROJECT=${PROJECT}" \ - . +DOCKER_BUILDKIT=1 docker build -t "${container}" -f "${file}" "${buildargs[@]}" . extract_var() { docker inspect "$1" | grep "$2" | sed -E "s/.*\"$2=(.*)\",?/\1/;q" diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 76eea7dbe..edafe4511 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -1,5 +1,6 @@ -ARG BASE_BRANCH -FROM quay.io/submariner/shipyard-dapper-base:${BASE_BRANCH} +ARG SHIPYARD_REPO=quay.io/submariner +ARG SHIPYARD_TAG=devel +FROM ${SHIPYARD_REPO}/shipyard-dapper-base:${SHIPYARD_TAG} ARG ORG ARG PROJECT diff --git a/Dockerfile.linting b/Dockerfile.linting index e4303d04f..5fd94e840 100644 --- a/Dockerfile.linting +++ b/Dockerfile.linting @@ -1,5 +1,6 @@ -ARG BASE_BRANCH -FROM quay.io/submariner/shipyard-linting:${BASE_BRANCH} +ARG SHIPYARD_REPO=quay.io/submariner +ARG SHIPYARD_TAG=devel +FROM ${SHIPYARD_REPO}/shipyard-linting:${SHIPYARD_TAG} ENV DAPPER_ENV="CI GITHUB_SHA MAKEFLAGS" \ DAPPER_SOURCE=/opt/linting diff --git a/Makefile.dapper b/Makefile.dapper index 6ed07ed04..51abc0f5f 100644 --- a/Makefile.dapper +++ b/Makefile.dapper @@ -3,12 +3,13 @@ ORG ?= submariner-io PROJECT ?= $(notdir $(CURDIR)) -export ORG -export PROJECT +SHIPYARD_TAG ?= $(BASE_BRANCH) +SHIPYARD_URL ?= https://raw.githubusercontent.com/submariner-io/shipyard/$(BASE_BRANCH) +export ORG PROJECT SHIPYARD_TAG SHIPYARD_URL Makefile.dapper.base: @echo Downloading $@ - @curl -sfLO https://raw.githubusercontent.com/submariner-io/shipyard/$(BASE_BRANCH)/$@ + @curl -sfLO $(SHIPYARD_URL)/$@ include Makefile.dapper.base diff --git a/Makefile.dapper.base b/Makefile.dapper.base index 4b9d08f02..781f3c9e0 100644 --- a/Makefile.dapper.base +++ b/Makefile.dapper.base @@ -28,7 +28,7 @@ else .dapper: @echo Downloading dapper - @curl -sfLO https://raw.githubusercontent.com/submariner-io/shipyard/$(BASE_BRANCH)/$@ + @curl -sfLO $(SHIPYARD_URL)/$@ @chmod +x .dapper @./.dapper -v @@ -58,7 +58,7 @@ $(filter-out .dapper prune-images shell targets $(NON_DAPPER_GOALS),$(MAKECMDGOA # The original dockerfiles will live in Shipyard and be downloaded by consuming projects. $(BASE_DAPPER) $(LINTING_DAPPER): @echo Downloading $@ - @curl -sfLO https://raw.githubusercontent.com/submariner-io/shipyard/$(BASE_BRANCH)/$@ + @curl -sfLO $(SHIPYARD_URL)/$@ # Run silently as the commands are pretty straightforward and `make` hasn't a lot to do $(LINTING_GOALS): DAPPER_ARGS := -f $(LINTING_DAPPER) diff --git a/README.md b/README.md index 90a0e8995..b06575c3c 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ The simplest Makefile would look like this: ```Makefile BASE_BRANCH=devel PROJECT=shipyard -export BASE_BRANCH -export PROJECT +SHIPYARD_URL=https://raw.githubusercontent.com/submariner-io/shipyard/$(BASE_BRANCH) +export BASE_BRANCH PROJECT SHIPYARD_URL ifneq (,$(DAPPER_HOST_ARCH)) @@ -67,7 +67,7 @@ else Makefile.dapper: @echo Downloading $@ - @curl -sfLO https://raw.githubusercontent.com/submariner-io/shipyard/$(BASE_BRANCH)/$@ + @curl -sfLO $(SHIPYARD_URL)/$@ include Makefile.dapper