From edfdd5c1a8df39e19b2c03f76e6382d456329908 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Fri, 3 May 2024 13:59:33 -0700 Subject: [PATCH] docker: move nvidia to scrypted-common --- .github/workflows/docker-common.yml | 62 ++++++++++++++++++++++- .github/workflows/docker.yml | 46 ----------------- install/docker/Dockerfile.nvidia | 12 ++--- install/docker/install-nvidia-graphics.sh | 16 ++++++ 4 files changed, 81 insertions(+), 55 deletions(-) create mode 100644 install/docker/install-nvidia-graphics.sh diff --git a/.github/workflows/docker-common.yml b/.github/workflows/docker-common.yml index 338394afa5..04b60690cd 100644 --- a/.github/workflows/docker-common.yml +++ b/.github/workflows/docker-common.yml @@ -7,7 +7,6 @@ jobs: build: name: Push Docker image to Docker Hub runs-on: self-hosted -# runs-on: ubuntu-latest strategy: matrix: NODE_VERSION: [ @@ -65,3 +64,64 @@ jobs: ghcr.io/koush/scrypted-common:${{ matrix.NODE_VERSION }}-${{ matrix.BASE }}-${{ matrix.FLAVOR }} cache-from: type=gha cache-to: type=gha,mode=max + + build-nvidia: + name: Push NVIDIA Docker image to Docker Hub + needs: build + runs-on: self-hosted + strategy: + matrix: + NODE_VERSION: [ + # "18", + "20" + ] + BASE: ["jammy"] + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up SSH + uses: MrSquaare/ssh-setup-action@v2 + with: + host: ${{ secrets.DOCKER_SSH_HOST_ARM64 }} + private-key: ${{ secrets.DOCKER_SSH_PRIVATE_KEY }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + platforms: linux/arm64 + append: | + - endpoint: ssh://${{ secrets.DOCKER_SSH_USER }}@${{ secrets.DOCKER_SSH_HOST_ARM64 }} + platforms: linux/arm64 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to Github Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image (scrypted-common) + uses: docker/build-push-action@v4 + with: + build-args: | + NODE_VERSION=${{ matrix.NODE_VERSION }} + BASE=ghcr.io/koush/scrypted-common:${{ matrix.BASE }}-${{ matrix.BASE }}-full + context: install/docker/ + file: install/docker/Dockerfile.nvidia + platforms: linux/amd64,linux/arm64 + push: true + tags: | + koush/scrypted-common:${{ matrix.NODE_VERSION }}-${{ matrix.BASE }}-nvidia + ghcr.io/koush/scrypted-common:${{ matrix.NODE_VERSION }}-${{ matrix.BASE }}-nvidia + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b999631be6..02489af3cf 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -93,49 +93,3 @@ jobs: ${{ github.event.inputs.tag == 'latest' && matrix.BASE == '20-jammy-lite' && matrix.SUPERVISOR == '.s6' && 'ghcr.io/koush/scrypted:lite-s6' || '' }} cache-from: type=gha cache-to: type=gha,mode=max - - build-nvidia: - needs: build - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: NPM Package Request - id: npm-request - uses: fjogeleit/http-request-action@v1 - with: - url: 'https://registry.npmjs.org/@scrypted/server' - method: 'GET' - - - name: Set NPM Version - id: package-version - run: echo "NPM_VERSION=${{ fromJson(steps.npm-request.outputs.response)['dist-tags'][ github.event.inputs.tag] }}" >> "$GITHUB_OUTPUT" - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Login to Github Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push NVIDIA Docker image - uses: docker/build-push-action@v4 - with: - build-args: | - BASE=ghcr.io/koush/scrypted:20-jammy-full.s6-v${{ steps.package-version.outputs.NPM_VERSION }} - context: install/docker/ - file: install/docker/Dockerfile.nvidia - push: true - tags: | - koush/scrypted:nvidia-v${{ steps.package-version.outputs.NPM_VERSION }} - ${{ github.event.inputs.tag == 'latest' && 'koush/scrypted:nvidia' || '' }} - - ghcr.io/koush/scrypted:nvidia-v${{ steps.package-version.outputs.NPM_VERSION }} - ${{ github.event.inputs.tag == 'latest' && 'ghcr.io/koush/scrypted:nvidia' || '' }} diff --git a/install/docker/Dockerfile.nvidia b/install/docker/Dockerfile.nvidia index 12efbb48ea..67c81493fa 100644 --- a/install/docker/Dockerfile.nvidia +++ b/install/docker/Dockerfile.nvidia @@ -1,10 +1,6 @@ -ARG BASE="ghcr.io/koush/scrypted" +ARG BASE="ghcr.io/koush/scrypted-common:20-jammy-full" FROM $BASE -ARG CUDA_VERSION=12-4 -RUN apt update -q \ - && apt install wget \ - && wget -qO /cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \ - && dpkg -i /cuda-keyring.deb \ - && apt update -q \ - && apt install -y cuda-nvcc-$CUDA_VERSION libcublas-$CUDA_VERSION libcudnn8 cuda-libraries-$CUDA_VERSION +# nvidia cudnn/libcublas etc. +# for some reason this is not provided by the nvidia container toolkit +RUN curl https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-nvidia-graphics.sh | bash diff --git a/install/docker/install-nvidia-graphics.sh b/install/docker/install-nvidia-graphics.sh new file mode 100644 index 0000000000..f35eef2c05 --- /dev/null +++ b/install/docker/install-nvidia-graphics.sh @@ -0,0 +1,16 @@ +if [ "$(uname -m)" = "x86_64" ] +then + export CUDA_VERSION=12-4 + echo "Installing NVIDIA graphics packages." + apt update -q \ + && apt install wget \ + && wget -qO /cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \ + && dpkg -i /cuda-keyring.deb \ + && apt update -q \ + && apt install -y cuda-nvcc-$CUDA_VERSION libcublas-$CUDA_VERSION libcudnn8 cuda-libraries-$CUDA_VERSION; + exit $? +else + echo "NVIDIA graphics will not be installed on this architecture." +fi + +exit 0