Skip to content

Commit

Permalink
Make Shipyard's location dynamic
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mkolesnik committed Dec 12, 2023
1 parent 92f736b commit bca49e5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
9 changes: 4 additions & 5 deletions .dapper
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.linting
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions Makefile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Makefile.dapper.base
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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

Expand Down

0 comments on commit bca49e5

Please sign in to comment.