Skip to content

Commit

Permalink
add name generation for base-images
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Morales <[email protected]>
  • Loading branch information
mauromorales committed Nov 29, 2023
1 parent 3c025c4 commit 5ff0d97
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 26 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/image-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,12 @@ jobs:
- name: Login to Quay Registry
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.changed-files.outputs.nvidia_any_changed == 'true' }}
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Build 🔧
- name: Build 🔧 & Push 🚀
if: steps.changed-files.outputs.nvidia_any_changed == 'true'
run: |
docker build --platform=linux/arm64 -t quay.io/kairos/ubuntu:nvidia-jetson-agx-orin-master -f ./images/Dockerfile.nvidia ./images
- name: Push 🚀
if: steps.changed-files.outputs.nvidia_any_changed == 'true'
run: |
docker push quay.io/kairos/ubuntu:nvidia-jetson-agx-orin-master
export IMAGE=$(FAMILY=ubuntu FLAVOR=ubuntu FLAVOR_RELEASE="20.04" MODEL=nvidia-jetson-agx-orin VARIANT=core TARGETARCH=arm64 REGISTRY_AND_ORG="quay.io/kairos" ./images/naming.sh container_artifact_base_name)
docker build --platform=linux/arm64 -t $IMAGE -f ./images/Dockerfile.nvidia ./images
docker push $IMAGE
nvidia-arm-core:
needs: build-nvidia-base
Expand All @@ -131,7 +129,8 @@ jobs:
flavor: ubuntu
flavor_release: "20.04"
family: ubuntu
base_image: quay.io/kairos/ubuntu:nvidia-jetson-agx-orin-master
# is there a way to run the naming.sh script here?
base_image: quay.io/kairos/ubuntu:20.04-core-arm64-nvidia-jetson-agx-orin-master
model: nvidia-jetson-agx-orin
worker: fast

Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/release-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,20 @@ jobs:
sudo iptables -I OUTPUT -d 169.254.169.254 -j DROP
- name: Login to Quay Registry
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Build 🔧
run: |
docker build --platform=linux/arm64 -t quay.io/kairos/ubuntu:nvidia-jetson-agx-orin-release -f ./images/Dockerfile.nvidia ./images
- name: Push 🚀
- name: Build 🔧 & Push 🚀
run: |
docker push quay.io/kairos/ubuntu:nvidia-jetson-agx-orin-release
export IMAGE=$(FAMILY=ubuntu FLAVOR=ubuntu FLAVOR_RELEASE="20.04" MODEL=nvidia-jetson-agx-orin VARIANT=core TARGETARCH=arm64 REGISTRY_AND_ORG="quay.io/kairos" BRANCH=release ./images/naming.sh container_artifact_base_name)
docker build --platform=linux/arm64 -t $IMAGE -f ./images/Dockerfile.nvidia ./images
docker push $IMAGE
nvidia-arm-core:
uses: ./.github/workflows/reusable-docker-arm-build.yaml
with:
flavor: ubuntu
flavor_release: "20.04"
family: ubuntu
base_image: quay.io/kairos/ubuntu:nvidia-jetson-agx-orin-release
# is there a way to run the naming.sh script here?
base_image: quay.io/kairos/ubuntu:20.04-core-arm64-nvidia-jetson-agx-orin-release
model: nvidia-jetson-agx-orin
worker: fast

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/reusable-docker-arm-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,26 @@ jobs:
ls -ltra build
ls -ltrh build
- name: Convert all json files into a reports.tar.gz file
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
run: |
export VERSION=$(cat build/VERSION)
cd build
filename=$(ls *-grype.json | head -n 1) && filename=${filename%%-grype.json}
sudo tar cvf "${filename}-scan-reports.tar.gz" *.json
- name: Push 🔧
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
run: |
docker push $(cat build/IMAGE)
- name: Sign image
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
env:
COSIGN_YES: true
run: |
export IMAGE=$(cat build/IMAGE)
docker push "$IMAGE" # Otherwise .RepoDigests will be empty for some reason
cosign sign $(docker image inspect --format='{{index .RepoDigests 0}}' "$IMAGE")
- name: Upload Image
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
run: |
curl https://luet.io/install.sh | sudo sh
IMAGE=$(cat build/IMAGE | sed 's/$/-img/')
Expand All @@ -148,19 +148,19 @@ jobs:
sudo -E docker push "$IMAGE"
sudo rm -rf build/IMAGE build/VERSION
- name: Release
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
with:
files: |
build/*scan-reports.tar.gz
- name: Prepare sarif files 🔧
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
run: |
mkdir sarif
sudo mv build/*.sarif sarif/
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
with:
sarif_file: 'sarif'
category: ${{ matrix.flavor }}
Expand Down
42 changes: 36 additions & 6 deletions images/naming.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ setEnvVarsFromJSON() {
}

common_artifact_name() {
if [ -z "$KAIROS_VERSION" ]; then
echo 'KAIROS_VERSION must be defined'
exit 1
fi

echo "$(common_artifact_base_name)-$KAIROS_VERSION"
}

common_artifact_base_name() {
if [ -z "$FLAVOR_RELEASE" ]; then
echo 'FLAVOR_RELEASE must be defined'
exit 1
Expand All @@ -35,15 +44,10 @@ common_artifact_name() {
echo 'MODEL must be defined'
exit 1
fi
if [ -z "$KAIROS_VERSION" ]; then
echo 'KAIROS_VERSION must be defined'
exit 1
fi

echo "$FLAVOR_RELEASE-$VARIANT-$TARGETARCH-$MODEL-$KAIROS_VERSION"
echo "$FLAVOR_RELEASE-$VARIANT-$TARGETARCH-$MODEL"
}


bootable_artifact_name() {
if [ -z "$FLAVOR" ]; then
echo 'FLAVOR must be defined'
Expand Down Expand Up @@ -79,6 +83,29 @@ container_artifact_name() {
echo "$REGISTRY_AND_ORG/$FLAVOR:$tag"
}

container_artifact_base_name() {
if [ -z "$BRANCH" ]; then
export BRANCH=master
fi

if [ -z "$FLAVOR" ]; then
echo 'FLAVOR must be defined'
exit 1
fi

if [ -z "$REGISTRY_AND_ORG" ]; then
echo 'REGISTRY_AND_ORG must be defined'
exit 1
fi

# quay.io doesn't accept "+" in the repo name
export KAIROS_VERSION="${KAIROS_VERSION/+/-}"
local tag
tag=$(common_artifact_base_name)

echo "$REGISTRY_AND_ORG/$FLAVOR:$tag-$BRANCH"
}

container_artifact_label() {
if [ -z "$KAIROS_VERSION" ]; then
echo 'KAIROS_VERSION must be defined'
Expand Down Expand Up @@ -126,6 +153,9 @@ case "$1" in
"container_artifact_repo")
container_artifact_repo
;;
"container_artifact_base_name")
container_artifact_base_name
;;
*)
echo "Function not found: $1"
exit 1
Expand Down

0 comments on commit 5ff0d97

Please sign in to comment.