-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreate-microshift-image.sh
executable file
·60 lines (49 loc) · 1.51 KB
/
create-microshift-image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -exuo pipefail
# Detect the system architecture
ARCH=$(uname -m)
# Map system architectures to container image architectures
case "$ARCH" in
"x86_64")
ARCH="amd64"
REPO="registry.ci.openshift.org/origin/release-scos"
;;
"aarch64")
ARCH="arm64"
REPO="quay.io/okd-arm/okd-arm-release"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
# Variables
VERSION_TAG="4.18.0-okd-scos.1"
IMAGE_NAME="quay.io/praveenkumar/microshift-okd"
IMAGE_ARCH_TAG="${IMAGE_NAME}:${VERSION_TAG}-${ARCH}"
CONTAINERFILE="okd/src/microshift-okd-multi-build.Containerfile"
# check if image already exist
if skopeo --override-os="linux" --override-arch="${ARCH}" inspect --format "Digest: {{.Digest}}" docker://${IMAGE_ARCH_TAG}; then
echo "${IMAGE_ARCH_TAG} already exist"
exit 0
fi
echo "Building image for architecture: $ARCH using repository: $REPO"
git clone https://github.com/openshift/microshift
pushd microshift
echo "Embed storage.conf and dns.conf to $CONTAINERFILE"
cp ../storage.conf ../00-dns.yaml .
sed -i '$a COPY storage.conf /etc/containers/storage.conf\nCOPY 00-dns.yaml /etc/microshift/config.d/00-dns.yaml' $CONTAINERFILE
# Build the image
sudo podman build \
--build-arg OKD_REPO="$REPO" \
--build-arg OKD_VERSION_TAG="$VERSION_TAG" \
--env WITH_FLANNEL=1 \
--env EMBED_CONTAINER_IMAGES=1 \
--file "$CONTAINERFILE" \
--tag "$IMAGE_ARCH_TAG" \
.
# Push the image
echo "Pushing image: $IMAGE_ARCH_TAG"
sudo podman push "$IMAGE_ARCH_TAG"
popd
rm -fr microshift