mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
Add script to build and push multi arch images
with the help of qemu-user-static we can run different architecute contains. more info at https://github.com/multiarch/qemu-user-static Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
4b540ffecc
commit
697ed32778
31
build-multi-arch-image.sh
Executable file
31
build-multi-arch-image.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
set -xe
|
||||
# "docker manifest" requires experimental feature enabled
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
|
||||
# ceph base image used for building multi architecture images
|
||||
dockerfile="deploy/cephcsi/image/Dockerfile"
|
||||
baseimg=$(awk -F = '/^ARG BASE_IMAGE=/ {print $NF}' "${dockerfile}")
|
||||
|
||||
# get image digest per architecture
|
||||
# {
|
||||
# "arch": "amd64",
|
||||
# "digest": "sha256:XXX"
|
||||
# }
|
||||
# {
|
||||
# "arch": "arm64",
|
||||
# "digest": "sha256:YYY"
|
||||
# }
|
||||
manifests=$(docker manifest inspect "${baseimg}" | jq '.manifests[] | {arch: .platform.architecture, digest: .digest}')
|
||||
# qemu-user-static is to enable an execution of different multi-architecture containers by QEMU
|
||||
# more info at https://github.com/multiarch/qemu-user-static
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
# build and push per arch images
|
||||
for ARCH in amd64 arm64; do
|
||||
ifs=$IFS
|
||||
IFS=
|
||||
digest=$(awk -v ARCH=${ARCH} '{if (archfound) {print $NF; exit 0}}; {archfound=($0 ~ "arch.*"ARCH)}' <<<"${manifests}")
|
||||
IFS=$ifs
|
||||
sed -i "s|\(^FROM.*\)${baseimg}.*$|\1${baseimg}@${digest}|" "${dockerfile}"
|
||||
GOARCH=${ARCH} make image-cephcsi
|
||||
done
|
@ -45,9 +45,8 @@ build_push_images() {
|
||||
# "docker manifest" requires experimental feature enabled
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
|
||||
# get baseimg (ceph/ceph:tag)
|
||||
dockerfile="deploy/cephcsi/image/Dockerfile"
|
||||
baseimg=$(awk 'NR==1{print $2}' "${dockerfile}")
|
||||
baseimg=$(awk -F = '/^ARG BASE_IMAGE=/ {print $NF}' "${dockerfile}")
|
||||
|
||||
# get image digest per architecture
|
||||
# {
|
||||
@ -58,7 +57,9 @@ build_push_images() {
|
||||
# "arch": "arm64",
|
||||
# "digest": "sha256:YYY"
|
||||
# }
|
||||
manifests=$("${CONTAINER_CMD:-docker}" manifest inspect "${baseimg}" | jq '.manifests[] | {arch: .platform.architecture, digest: .digest}')
|
||||
manifests=$(docker manifest inspect "${baseimg}" | jq '.manifests[] | {arch: .platform.architecture, digest: .digest}')
|
||||
# qemu-user-static is to enable an execution of different multi-architecture containers by QEMU
|
||||
# more info at https://github.com/multiarch/qemu-user-static
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
# build and push per arch images
|
||||
for ARCH in amd64 arm64; do
|
||||
|
@ -11,13 +11,13 @@ ARG GO_ARCH
|
||||
ARG SRC_DIR
|
||||
ARG GIT_COMMIT
|
||||
ARG GOROOT=/usr/local/go
|
||||
RUN dnf install libcephfs-devel librados-devel librbd-devel /usr/bin/cc make -y
|
||||
|
||||
RUN mkdir -p ${GOROOT} && \
|
||||
curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${GO_ARCH}.tar.gz | tar xzf - -C ${GOROOT} --strip-components=1
|
||||
|
||||
RUN dnf install libcephfs-devel librados-devel librbd-devel /usr/bin/cc make -y
|
||||
|
||||
ENV GOROOT=$GOROOT \
|
||||
ENV GOROOT=${GOROOT} \
|
||||
GOPATH=/go \
|
||||
CGO_ENABLED=1 \
|
||||
GIT_COMMIT="${GIT_COMMIT}" \
|
||||
@ -40,8 +40,8 @@ FROM ceph/ceph:v15
|
||||
ARG SRC_DIR
|
||||
|
||||
LABEL maintainers="Ceph-CSI Authors" \
|
||||
version=$CSI_IMAGE_VERSION \
|
||||
architecture=$GO_ARCH \
|
||||
version=${CSI_IMAGE_VERSION} \
|
||||
architecture=${GO_ARCH} \
|
||||
description="Ceph-CSI Plugin"
|
||||
|
||||
COPY --from=0 ${SRC_DIR}/_output/cephcsi /usr/local/bin/cephcsi
|
||||
|
Loading…
Reference in New Issue
Block a user