Skip to content

Commit

Permalink
base image variable
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhedarV authored Sep 23, 2024
1 parent 0b35973 commit 9afd21c
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions .github/workflows/tarrr_file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,29 @@ jobs:
ls -al ${{ github.workspace }}/${{ env.XRT_VERSION_PATCH }}/Dockerfile
shell: bash

- name: Build Docker images
run: |
for package_file in ${{ github.workspace }}/${{ env.XRT_VERSION_PATCH }}/Dockerfile/*-xrt.rpm ${{ github.workspace }}/${{ env.XRT_VERSION_PATCH }}/Dockerfile/*-xrt.deb; do
echo "Building image for $package_file"
image_tag=$(basename $package_file | sed 's/\.[^.]*$//')
if [[ $package_file == *centos_8.1* || $package_file == *amazonlinux20202011111* ]]; then
base_image="centos:8"
elif [[ $package_file == *ubuntu_20.04* ]]; then
base_image="ubuntu:20.04"
elif [[ $package_file == *ubuntu_22.04* ]]; then
base_image="ubuntu:22.04"
else
base_image="ubuntu:18.04"
fi
echo "Using base image: $base_image"
docker build --build-arg PACKAGE_FILE=$(basename $package_file) --build-arg BASE_IMAGE=$base_image -t xrt_image:$image_tag -f ${{ github.workspace }}/${{ env.XRT_VERSION_PATCH }}/Dockerfile/Dockerfile ${{ github.workspace }}/${{ env.XRT_VERSION_PATCH }}/Dockerfile
done
shell: bash
- name: Build Docker images
run: |
set -e # Exit on any error
for package_file in "$GITHUB_WORKSPACE/${{ env.XRT_VERSION_PATCH }}/Dockerfile/"*-xrt.rpm "$GITHUB_WORKSPACE/${{ env.XRT_VERSION_PATCH }}/Dockerfile/"*-xrt.deb; do
echo "Building image for $package_file"
image_tag=$(basename "$package_file" | sed 's/\.[^.]*$//')
# Use [ ... ] for POSIX compliance
if [ "$package_file" = *centos_8.1* ] || [ "$package_file" = *amazonlinux20202011111* ]; then
base_image="centos:8"
elif [ "$package_file" = *ubuntu_20.04* ]; then
base_image="ubuntu:20.04"
elif [ "$package_file" = *ubuntu_22.04* ]; then
base_image="ubuntu:22.04"
else
base_image="ubuntu:18.04"
fi
echo "Using base image: $base_image"
docker build --build-arg PACKAGE_FILE=$(basename "$package_file") --build-arg BASE_IMAGE="$base_image" -t "xrt_image:$image_tag" -f "$GITHUB_WORKSPACE/${{ env.XRT_VERSION_PATCH }}/Dockerfile/Dockerfile" "$GITHUB_WORKSPACE/${{ env.XRT_VERSION_PATCH }}/Dockerfile"
done
shell: bash



- name: Authenticate with Harbor
Expand Down

0 comments on commit 9afd21c

Please sign in to comment.