Skip to content

Commit 45a2789

Browse files
committed
Add Rancher scripts
- Change release tags to rancher versions - Support Rancher Prime in builds - Use default buildx builder Signed-off-by: Derek Nola <derek.nola@suse.com>
1 parent eae6077 commit 45a2789

11 files changed

Lines changed: 187 additions & 0 deletions

File tree

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# Add the following 'help' target to your Makefile
1616
# And add help text after each target name starting with '\#\#'
1717

18+
# Only call make targets from within .scipts/*, which overrides relevant build variables with rancher specific values
19+
1820
.DEFAULT_GOAL:=help
1921

2022
.EXPORT_ALL_VARIABLES:
@@ -282,3 +284,42 @@ release: builder clean
282284
build-docs:
283285
pip install -r docs/requirements.txt
284286
mkdocs build --config-file mkdocs.yml
287+
288+
# Derived from the release target, but only builds and pushes a single image.
289+
# Binaries are built separately.
290+
# Changed the name to match existing rancher published image tags
291+
.PHONY: push-image
292+
push-image: REGISTRY=$(REPO)
293+
push-image: BUILDX_PLATFORMS=$(TARGET_PLATFORMS)
294+
push-image: builder
295+
docker buildx build \
296+
--sbom=true \
297+
--attest type=provenance,mode=max \
298+
$(IID_FILE_FLAG) \
299+
--no-cache \
300+
--push \
301+
--progress plain \
302+
--platform $(BUILDX_PLATFORMS) \
303+
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
304+
--build-arg VERSION="$(TAG)" \
305+
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
306+
--build-arg BUILD_ID="$(BUILD_ID)" \
307+
-t $(REGISTRY)/nginx-ingress-controller:$(TAG) rootfs
308+
309+
.PHONY: push-chroot-image
310+
push-chroot-image: REGISTRY=$(REPO)
311+
push-chroot-image: BUILDX_PLATFORMS=$(TARGET_PLATFORMS)
312+
push-chroot-image: builder
313+
docker buildx build \
314+
--sbom=true \
315+
--attest type=provenance,mode=max \
316+
$(IID_FILE_FLAG) \
317+
--no-cache \
318+
--push \
319+
--progress plain \
320+
--platform $(BUILDX_PLATFORMS) \
321+
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
322+
--build-arg VERSION="$(TAG)" \
323+
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
324+
--build-arg BUILD_ID="$(BUILD_ID)" \
325+
-t $(REGISTRY)/nginx-ingress-controller-chroot:$(TAG) rootfs -f rootfs/Dockerfile-chroot

scripts/build-base-image

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
source $(dirname $0)/version
5+
6+
cd $(dirname $0)/..
7+
8+
# If #GIT_TAG is present, then we build base images for all supported platforms,
9+
# pushing them to dockerhub for use in the package stage. They must be pushed, this
10+
# an inherent limitation of the buildx cache. See https://github.com/moby/buildkit/issues/2343
11+
if [[ -n "$GIT_TAG" ]] && [ "$GITHUB_ACTIONS" = "true" ]; then
12+
ARCH="amd64 arm64" PLATFORMS="linux/amd64,linux/arm64" TAG=${NGINX_TAG} make -C images/nginx push
13+
else
14+
# Only build the images for the current host platform, using regular docker build
15+
TAG=${NGINX_TAG} make -C images/nginx build BUILDER=default
16+
fi

scripts/build-binary

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
source $(dirname $0)/version
5+
cd $(dirname $0)/..
6+
7+
# If #GIT_TAG is present, then we build binaries
8+
if [[ -n "$GIT_TAG" ]] && [ "$GITHUB_ACTIONS" = "true" ]; then
9+
ARCH=amd64 PLATFORM=amd64 make build
10+
ARCH=arm64 PLATFORM=arm64 make build
11+
else
12+
# Only build the images for the current host platform, using regular docker build
13+
make build BUILDER=default # goboring hardened binaries
14+
fi

scripts/ci

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
cd $(dirname $0)
5+
6+
./validate
7+
./test
8+
# if e2e run ./e2e-test
9+
./build-base-image
10+
./build-binary
11+
./package

scripts/dev-env

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# Use ./scripts/build-binary and ./scripts/package to build the dev-env image
3+
set -e -x
4+
5+
source $(dirname $0)/version
6+
7+
cd $(dirname $0)/..
8+
9+
make dev-env

scripts/e2e-build

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
source $(dirname $0)/version
5+
6+
cd $(dirname $0)/..
7+
8+
if ! command -v kind &> /dev/null; then
9+
./scripts/e2e-test-install-deps
10+
fi
11+
12+
TAG=${NGINX_TAG}-e2e make -C images/nginx build BUILDER=default

scripts/e2e-test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
source $(dirname $0)/version
5+
6+
cd $(dirname $0)/..
7+
8+
# If running e2e locally over and over, you can skip image creation
9+
SKIP_IMAGE_CREATION=${SKIP_IMAGE_CREATION:-false} NGINX_BASE_IMAGE=${BASE_IMAGE}-e2e make kind-e2e-test BUILDER=default
10+

scripts/e2e-test-install-deps

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
ARCH=${ARCH:-amd64}
5+
K8S_STABLE=$(curl -L -s https://dl.k8s.io/release/stable.txt)
6+
7+
curl -LO "https://dl.k8s.io/release/${K8S_STABLE}/bin/linux/${ARCH}/kubectl"
8+
curl -LO "https://dl.k8s.io/${K8S_STABLE}/bin/linux/${ARCH}/kubectl.sha256"
9+
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
10+
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
11+
kubectl version --client
12+
13+
curl -Lo ./kind "https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-${ARCH}"
14+
install -o root -g root -m 0755 kind /usr/local/bin/kind
15+
kind --version
16+
17+
curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
18+
19+
go get github.com/onsi/ginkgo/ginkgo

scripts/package

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
source $(dirname $0)/version
5+
cd $(dirname $0)/..
6+
7+
# Only build the final images for the current host platform, using regular docker build.
8+
# Only used for local builds, CI uses external GH actions + make targets to build and push images
9+
make image BUILDER=default
10+
make image-chroot BUILDER=default

scripts/test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
source $(dirname $0)/version
5+
6+
cd $(dirname $0)/..
7+
8+
echo Running general unit tests
9+
make test
10+
echo Running lua unit tests
11+
make lua-test

0 commit comments

Comments
 (0)