mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-28 18:18:41 +00:00
Compare commits
5 Commits
feat/use-o
...
173-airgap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dceff77c95 | ||
|
|
b4ad5f8d85 | ||
|
|
cffb825711 | ||
|
|
1af8b857c0 | ||
|
|
fceba58cd0 |
28
hack/build-images.sh
Executable file
28
hack/build-images.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o pipefail
|
||||
set -e
|
||||
|
||||
REGISTRY=$1
|
||||
NAME=$2
|
||||
TYPE=$3
|
||||
PUSH=$4
|
||||
LOAD=$5
|
||||
|
||||
# an example for packages/system/capi-operator, native image and transformed one
|
||||
# registry.k8s.io/capi-operator/cluster-api-operator:v0.8.1
|
||||
# ghcr.io/aenix-io/cozystack/system/capi-operator/cluster-api-operator:v0.8.1
|
||||
|
||||
find images -mindepth 1 -maxdepth 1 -type d | \
|
||||
while read dockerfile_path; do
|
||||
image_name=$(echo $dockerfile_path | awk -F/ '{print $2}')
|
||||
tag=$(egrep -o "FROM .*$image_name.*" $dockerfile_path/Dockerfile | awk -F: '{print $NF}')
|
||||
docker buildx build $dockerfile_path \
|
||||
--provenance=false \
|
||||
--tag=$REGISTRY/$TYPE/$image_name:$tag \
|
||||
--cache-from=type=registry,ref=$REGISTRY/$TYPE/$image_name:latest \
|
||||
--cache-to=type=inline \
|
||||
--push=$PUSH \
|
||||
--load=$LOAD
|
||||
done
|
||||
|
||||
32
hack/update-dockerfiles.sh
Executable file
32
hack/update-dockerfiles.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o pipefail
|
||||
set -e
|
||||
|
||||
function update_dockerfile() {
|
||||
local image=$1
|
||||
local image_name=$(echo $image | awk -F/ '{print $NF}' | awk -F: '{print $1}')
|
||||
|
||||
[[ -z $image_name ]] && { echo "image_name is empty for image: $image">&2; exit 1; }
|
||||
mkdir -p images/$image_name
|
||||
if [[ ! -f images/$image_name/Dockerfile ]];
|
||||
then
|
||||
echo "FROM $image" > images/$image_name/Dockerfile
|
||||
else
|
||||
sed -i "s|FROM .*$image_name.*|FROM $image|" images/$image_name/Dockerfile
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function with_helm() {
|
||||
helm template . | awk '/^[ \t"-]*image["]*: [a-zA-Z0-9/:@"\.-]+$/{print $NF}' | sed 's/"//g' | \
|
||||
while read image; do
|
||||
update_dockerfile $image
|
||||
done
|
||||
}
|
||||
|
||||
function with_grep() {
|
||||
}
|
||||
|
||||
[[ -z $1 ]] && with_helm || $1
|
||||
|
||||
@@ -1,11 +1,42 @@
|
||||
NAME=capi-operator
|
||||
NAMESPACE=cozy-cluster-api
|
||||
TYPE=system
|
||||
|
||||
include ../../../scripts/common-envs.mk
|
||||
include ../../../scripts/package-system.mk
|
||||
|
||||
update:
|
||||
update: update-charts update-dockerfiles update-images
|
||||
|
||||
update-charts:
|
||||
rm -rf charts
|
||||
helm repo add capi-operator https://kubernetes-sigs.github.io/cluster-api-operator
|
||||
helm repo update capi-operator
|
||||
helm pull capi-operator/cluster-api-operator --untar --untardir charts
|
||||
rm -rf charts/cluster-api-operator/charts
|
||||
|
||||
update-dockerfiles:
|
||||
../../../hack/update-dockerfiles.sh with_helm
|
||||
|
||||
components := $(subst /,,$(subst images/,,$(dir $(wildcard images/*/Dockerfile))))
|
||||
img_targets := $(addprefix image-,$(components))
|
||||
|
||||
update-images: $(img_targets)
|
||||
|
||||
.PHONY: $(img_targets)
|
||||
$(img_targets):
|
||||
@$(eval name := $(subst image-,,$@))
|
||||
@$(eval tag := $(shell egrep -o "FROM .*$(name).*" images/$(name)/Dockerfile | awk -F: '{print $$NF}'))
|
||||
BUILDX_METADATA_PROVENANCE=0 docker buildx build images/$(name)/ \
|
||||
--provenance false \
|
||||
--tag $(subst //,/,$(REGISTRY)/$(TYPE)/$(name):$(tag)) \
|
||||
--cache-from type=registry,ref=$(subst //,/,$(REGISTRY)/$(TYPE)/$(name):latest) \
|
||||
--cache-to type=inline \
|
||||
--metadata-file images/$(name).json \
|
||||
--push=$(PUSH) \
|
||||
--load=$(LOAD) && \
|
||||
img_name=$$(jq -r '."image.name" | split(":")[:-1] | join(":")' images/$(name).json) \
|
||||
yq -i '.$(name).image.manager.repository = ("$${img_name}"|envsubst(nu,ne))' values.yaml && \
|
||||
img_tag=$$(jq -r '."image.name" | split(":")[-1]' images/$(name).json) \
|
||||
img_digest=$$(jq -r '."containerimage.digest"' images/$(name).json) \
|
||||
yq -i '.$(name).image.manager.tag = ("$${img_tag}@$${img_digest}"|envsubst(nu,ne))' values.yaml
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"buildx.build.ref": "default/default/7nxaun3sgw6z95qhgc4c873qo",
|
||||
"containerimage.config.digest": "sha256:0ff1e569cc97f686d6c0c9ed6e6396c72eca93df746e7ca469f97124cae1e73d",
|
||||
"containerimage.digest": "sha256:79282412e0b891630235ecf919c45b0531f25a0926825385a51bb2a7dde880fb",
|
||||
"image.name": "localhost:5000/aenix-io/cozystack/system/cluster-api-operator:v0.8.1"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
FROM registry.k8s.io/capi-operator/cluster-api-operator:v0.8.1
|
||||
5
packages/system/capi-operator/values.yaml
Normal file
5
packages/system/capi-operator/values.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
cluster-api-operator:
|
||||
image:
|
||||
manager:
|
||||
repository: "localhost:5000/aenix-io/cozystack/system/cluster-api-operator"
|
||||
tag: "v0.8.1@sha256:79282412e0b891630235ecf919c45b0531f25a0926825385a51bb2a7dde880fb"
|
||||
Reference in New Issue
Block a user