diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index b15bb62..2b0dd31 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -4,7 +4,7 @@ name: docker-build # Only build base when any of the files in the base directory are modified on: push: - branches: [master, build_jetson] + branches: [master, two_x86] tags: - '*' workflow_dispatch: @@ -20,6 +20,7 @@ jobs: strategy: fail-fast: false matrix: + upstream: [nvda, bare] platform: - linux/amd64 - linux/arm64 @@ -34,7 +35,8 @@ jobs: name: Prepare run: | platform=${{ matrix.platform }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + upstream=${{ matrix.upstream }} + echo "PLATFORM_PAIR=${platform//\//-}-upstream" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 @@ -42,22 +44,35 @@ jobs: name: Set platform-specific build-args id: set_build_args run: | - export $(cat build.bash | grep UPSTREAM_X86_64 | sed 's/^export //') - export $(cat build.bash | grep UPSTREAM_AARCH64 | sed 's/^export //') + # Read the upstream images from build.bash + export $(cat build.bash | grep UPSTREAM_X86_64_NVDA | sed 's/^export //') + export $(cat build.bash | grep UPSTREAM_AARCH64_NVDA | sed 's/^export //') + export $(cat build.bash | grep UPSTREAM_X86_64_BARE | sed 's/^export //') + export $(cat build.bash | grep UPSTREAM_AARCH64_BARE | sed 's/^export //') if [ "${{ matrix.platform }}" = "linux/amd64" ]; then - echo "upstream_image=$UPSTREAM_X86_64" >> $GITHUB_ENV + if [ "${{ matrix.upstream }}" = "bare" ]; then + echo "upstream_image=$UPSTREAM_X86_64_BARE" >> $GITHUB_ENV + else + echo "upstream_image=$UPSTREAM_X86_64_NVDA" >> $GITHUB_ENV + fi elif [ "${{ matrix.platform }}" = "linux/arm64" ]; then - echo "upstream_image=$UPSTREAM_AARCH64" >> $GITHUB_ENV + if [ "${{ matrix.upstream }}" = "bare" ]; then + echo "upstream_image=$UPSTREAM_AARCH64_BARE" >> $GITHUB_ENV + else + echo "upstream_image=$UPSTREAM_AARCH64_NVDA" >> $GITHUB_ENV + fi else echo "Architecture not supported" exit 1 fi + echo "Architecture: ${{ matrix.platform }}" + echo "Upstream option: ${{ matrix.upstream }}" - name: Docker meta id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY_IMAGE }} + images: ${{ env.REGISTRY_IMAGE }}-${{ matrix.upstream }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -79,7 +94,7 @@ jobs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} build-args: upstream_image=${{ env.upstream_image }} - outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true + outputs: type=image,name=${{ env.REGISTRY_IMAGE }}-${{ matrix.upstream }},push-by-digest=true,name-canonical=true,push=true - name: Export digest run: | @@ -96,6 +111,10 @@ jobs: retention-days: 1 merge: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + upstream: [nvda, bare] needs: - build steps: @@ -114,7 +133,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY_IMAGE }} + images: ${{ env.REGISTRY_IMAGE }}-${{ matrix.upstream }} - name: Login to Docker Hub uses: docker/login-action@v3 @@ -126,8 +145,8 @@ jobs: working-directory: /tmp/digests run: | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + $(printf '${{ env.REGISTRY_IMAGE }}-${{ matrix.upstream }}@sha256:%s ' *) - name: Inspect image run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}-${{ matrix.upstream }}:${{ steps.meta.outputs.version }} diff --git a/build.bash b/build.bash index 2544f1d..f22bf08 100755 --- a/build.bash +++ b/build.bash @@ -20,13 +20,16 @@ set -eo pipefail -# Upstream images for x86_64 and aarch64 -# For x86_64, use the CUDA 11.4.3 image -# For aarch64, use the L4T PyTorch image +# Upstream images for x86_64 and aarch64, for both Nvidia and non-Nvidia +# For x86_64 and aarch64 non-Nvidia, use the Ubuntu 20.04 image +# For x86_64 Nvidia, use the CUDA 11.4.3 image +# For aarch64 Nvidia, use the L4T PyTorch image # Important: do not modify the variable name as it is used by the Github action # to build the image -UPSTREAM_X86_64=nvcr.io/nvidia/cuda:11.4.3-devel-ubuntu20.04 -UPSTREAM_AARCH64=nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3 +UPSTREAM_X86_64_NVDA=nvcr.io/nvidia/cuda:11.4.3-devel-ubuntu20.04 +UPSTREAM_AARCH64_NVDA=nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3 +UPSTREAM_X86_64_BARE=ubuntu:20.04 +UPSTREAM_AARCH64_BARE=ubuntu:20.04 # Check that the current user has UID 1000. if [ $(id -u) -ne 1000 ] @@ -43,30 +46,38 @@ then elif [ $# -eq 1 ] then # No image type is provided, build x86 by default - upstream=$UPSTREAM_X86_64 + echo "Building x86_64 image by default" + upstream=$UPSTREAM_X86_64_BARE architecture="x86_64" + tag_addition="bare" elif [ $# -eq 2 ] then - # The second argument should be x86_64 or aarch64 + # The second argument should be x86_64_nvda aarch64_nvda or x86_64 if [ "$2" = "x86_64" ] then - upstream=$UPSTREAM_X86_64 - elif [ "$2" = "aarch64" ] + upstream=$UPSTREAM_X86_64_BARE + tag_addition="bare" + elif [ "$2" = "aarch64_nvda" ] then - upstream=$UPSTREAM_AARCH64 + upstream=$UPSTREAM_AARCH64_NVDA + tag_addition="nvda" + elif [ "$2" = "x86_64_nvda" ] + then + upstream=$UPSTREAM_X86_64_NVDA + tag_addition="nvda" else - echo "Usage: $0 directory-name [x86_64|aarch64]" + echo "Usage: $0 directory-name [x86_64|x86_64_nvda|aarch64_nvda]" exit 1 fi architecture=$2 else - echo "Usage: $0 directory-name [x86_64|aarch64]" + echo "Usage: $0 directory-name [x86_64|x86_64_nvda|aarch64_nvda]" exit 1 fi # Create the image name and tag user_id=$(id -u) -image_name=$(basename "$1") +image_name="$(basename "$1")-$tag_addition" revision=$(git describe --tags --long) image_plus_tag=kumarrobotics/$image_name:$revision @@ -88,7 +99,7 @@ fi docker build --rm -t $image_plus_tag \ --build-arg user_id=$user_id \ --build-arg upstream_image=$upstream \ - -f $DIR/$image_name/Dockerfile . + -f $DIR/$1/Dockerfile . echo "Built $image_plus_tag and tagged as $image_name:latest" # Create "latest" tag