Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Clone images to local oci repo before building #518

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading