Skip to content

Commit

Permalink
chore: Clone images to local oci repo before building (#518)
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 <[email protected]>
  • Loading branch information
smoser authored Oct 3, 2023
1 parent 96dbbe5 commit 957000a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
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
6 changes: 2 additions & 4 deletions doc/hacking.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ The Makefile supports setting some variables for quicker development.
or just to speed up iterative development, you can copy these images to a local
oci repository or local zot repository and point the Make system at that.

$ OCI_D=/tmp/my.oci
$ for d in alpine:edge centos:latest ubuntu:latest; do
skopeo copy docker://$d oci:$OCI_D:$d; done
$ make docker-clone STACKER_DOCKER_BASE=docker:// CLONE_D=/tmp/my-oci

And then invoke make like:

make STACKER_DOCKER_BASE="oci:$OCI_D:"
make STACKER_DOCKER_BASE="oci:/tmp/my-oci:"

I have a nightly sync job that copies these to a local zot repo and then I can build with:

Expand Down

0 comments on commit 957000a

Please sign in to comment.