Skip to content

Commit

Permalink
chore: Clone images to local oci repo before building
Browse files Browse the repository at this point in the history
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 <smoser@brickies.net>
  • Loading branch information
smoser committed Oct 3, 2023
1 parent 96dbbe5 commit b003fce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b003fce

Please sign in to comment.