Skip to content

Commit

Permalink
fix: build cos-uploader for amd64 and arm64 (#376)
Browse files Browse the repository at this point in the history
* feat: add cos-uploader build script

Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>

* ci: add cos-uploader to build scripts

Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>

* chore: replace cos-uploader image

Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>

---------

Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
  • Loading branch information
AlessandroPomponio authored Jul 30, 2024
1 parent da435c8 commit c200794
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 2 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/push-updated-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
branches:
- master
paths:
- 'src/dataset-operator/**'
- "src/dataset-operator/**"
- "src/cos-uploader/**"

jobs:
dataset-operator:
Expand Down Expand Up @@ -45,3 +46,22 @@ jobs:
run: |
cd src/generate-keys
./build_multiarch_generate_keys.sh -p ${{ vars.REGISTRY_URL }}
cos-uploader:
runs-on: ubuntu-latest
steps:
- name: Clone Datashim
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ${{ vars.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push COS Uploader
run: |
cd src/cos-uploader
./build_multiarch_cos_uploader.sh -p ${{ vars.REGISTRY_URL }}
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ jobs:
./build_and_push_multiarch_csinfs.sh ${{ vars.REGISTRY_URL }} ${{ steps.vars.outputs.sha_short }}
docker buildx prune
- name: Build and push COS uploader image
run: |
cd src/cos-uploader
./build_multiarch_cos_uploader.sh -p ${{ vars.REGISTRY_URL }} ${{ github.ref_name }}
- name: Install Helm
uses: azure/setup-helm@v3

Expand Down
86 changes: 86 additions & 0 deletions src/cos-uploader/build_multiarch_cos_uploader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash
set -e

print_usage() {
echo "usage: $0 [-p] <REGISTRY_URL> <VERSION>"
echo "Use -p to build and push multiarch images"
}

PUSH="false"
while getopts 'p' flag; do
case "$flag" in
p)
PUSH="true"
;;
?)
print_usage >&2
exit 1
;;
esac
done

shift $((OPTIND-1))

REGISTRY_URL="${1:-quay.io/datashim-io}"
VERSION="${2:-latest}"

docker_build () {
docker buildx build --platform linux/amd64 -t ${REGISTRY_URL}/cos-uploader:${VERSION} .
docker buildx build --load -t ${REGISTRY_URL}/cos-uploader:${VERSION} .
}

docker_build_and_push () {
docker buildx build --platform linux/amd64,linux/arm64 --push -t ${REGISTRY_URL}/cos-uploader:${VERSION} .
}

podman_build () {
podman manifest create ${REGISTRY_URL}/cos-uploader:${VERSION}
podman buildx build --platform linux/amd64,linux/arm64 --manifest ${REGISTRY_URL}/cos-uploader:${VERSION} .
}

podman_push () {
podman manifest push ${REGISTRY_URL}/cos-uploader:${VERSION}

}

DOCKERCMD="docker"
ALTDOCKERCMD="podman"
if !(command -v ${DOCKERCMD} &> /dev/null)
then
echo "Docker command not found"
if !(command -v ${ALTDOCKERCMD} &> /dev/null)
then
echo "Neither ${DOCKERCMD} nor ${ALTDOCKERCMD} commands found.. cannot build "
exit 1
else
DOCKERCMD=${ALTDOCKERCMD}
fi
else
echo "Docker command found"
cmd_type=$(type -t ${DOCKERCMD})
if [ $cmd_type == "alias" ]
then
echo "${DOCKERCMD} is an alias, switching to ${ALTDOCKERCMD}"
DOCKERCMD=${ALTDOCKERCMD}
fi
fi

if [ $PUSH == "true" ]
then
echo "pushing images to the registry"
if [ ${DOCKERCMD} == "docker" ]
then
docker_build_and_push
else
podman_build
podman_push
fi
else
echo "building image locally"
if [ ${DOCKERCMD} == "docker" ]
then
docker_build
else
podman_build
fi
fi
2 changes: 1 addition & 1 deletion src/dataset-operator/controllers/archive_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func getPodDataDownload(dataset *datasets.Dataset, operatorNamespace string) (*b
}
podSpec := corev1.PodSpec{
Containers: []corev1.Container{{
Image: "yiannisgkoufas/cos-uploader:latest",
Image: "quay.io/datashim-io/cos-uploader:latest",
ImagePullPolicy: corev1.PullAlways,
Name: "cos-uploader",
Command: command,
Expand Down

0 comments on commit c200794

Please sign in to comment.