From b003fce9ff4b3b14daa70b94024d98a577a43bf4 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 2 Oct 2023 20:55:10 -0400 Subject: [PATCH] chore: Clone images to local oci repo before building This adds a make target 'docker-clone' which will copy the required docker images to a local oci dir specified by CLONE_D. You can then use that oci dir as STACKER_DOCKER_BASE. So: make docker-clone CLONE_D=/tmp/my-oci export STACKER_DOCKER_BASE=oci:/tmp/my-oci: make ... Signed-off-by: Scott Moser --- .github/workflows/build.yaml | 4 ++++ Makefile | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6c0f7555..c91c0260 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -57,6 +57,7 @@ jobs: echo "GOCACHE=$gopath/gocache" >> $GITHUB_ENV echo "PATH=$gopath/bin:$PATH" >> $GITHUB_ENV echo "SLOW_TEST=${{inputs.slow-test}}" >> $GITHUB_ENV + echo "STACKER_DOCKER_BASE=oci:$PWD/.build/oci-clone:" >> $GITHUB_ENV echo "PWD=$PWD" cat "$GITHUB_ENV" @@ -69,6 +70,9 @@ jobs: GO111MODULE=off go get github.com/opencontainers/umoci/cmd/umoci make download-tools echo "running kernel is: $(uname -a)" + - name: docker-clone + run: | + make docker-clone "STACKER_DOCKER_BASE=docker://" CLONE_D="$PWD/.build/oci-clone" - name: Go-download run: | make go-download diff --git a/Makefile b/Makefile index dd9b2654..276254af 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ export GOCACHE = $(GOPATH)/gocache GO_SRC=$(shell find pkg cmd -name \*.go) VERSION?=$(shell git describe --tags || git rev-parse HEAD) VERSION_FULL?=$(if $(shell git status --porcelain --untracked-files=no),$(VERSION)-dirty,$(VERSION)) +HASH = \# LXC_VERSION?=$(shell pkg-config --modversion lxc) @@ -21,6 +22,7 @@ STACKER_DOCKER_BASE?=docker:// STACKER_BUILD_BASE_IMAGE?=$(STACKER_DOCKER_BASE)alpine:edge STACKER_BUILD_CENTOS_IMAGE?=$(STACKER_DOCKER_BASE)centos:latest STACKER_BUILD_UBUNTU_IMAGE?=$(STACKER_DOCKER_BASE)ubuntu:latest +STACKER_BUILD_IMAGES = $(STACKER_BUILD_BASE_IMAGE) $(STACKER_BUILD_CENTOS_IMAGE) $(STACKER_BUILD_UBUNTU_IMAGE) LXC_CLONE_URL?=https://github.com/lxc/lxc LXC_BRANCH?=stable-5.0 @@ -116,7 +118,19 @@ test: stacker $(REGCLIENT) $(ZOT) $(shell [ -z $(PRIVILEGE_LEVEL) ] || echo --privilege-level=$(PRIVILEGE_LEVEL)) \ $(patsubst %,test/%.bats,$(TEST)) -.PHONY: + +CLONE_D = $(BUILD_D)/oci-clone +CLONE_RETRIES = 3 +.PHONY: docker-clone +docker-clone: + mkdir -p $(CLONE_D) + vr() { echo "$$" "$$@" 1>&2; "$$@"; }; \ + for u in $(STACKER_BUILD_IMAGES); do \ + name=$${u$(HASH)$(HASH)*/}; \ + vr skopeo copy --retry-times $(CLONE_RETRIES) "$$u" "oci:$(CLONE_D):$${name}"; \ + done + +.PHONY: show-info show-info: @echo BUILD_D=$(BUILD_D) @go env