From d3102fe3f40f823d540e84be663cda155447f8c7 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Mon, 5 Feb 2024 10:18:07 -0700 Subject: [PATCH] Adding an ImageStream for OpenShift AI and github workflow We want GitHub actions to build the container image and publickly publish the image. --- .github/workflows/build-image.yaml | 68 +++++++++++++++++++ Dockerfile | 9 ++- .../imagestreams/vscode-java/imagestream.yaml | 29 ++++++++ 3 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-image.yaml create mode 100644 cluster-scope/base/image.openshift.io/imagestreams/vscode-java/imagestream.yaml diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 0000000..c9c02a2 --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -0,0 +1,68 @@ +name: Build container image + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [main] + # Publish semver tags as releases. + tags: ['v*.*.*'] + pull_request: + branches: [main] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern=v{{major}} + type=ref,event=branch + type=ref,event=pr + type=sha + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + diff --git a/Dockerfile b/Dockerfile index 9ccdb2c..83672dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,17 @@ FROM quay.io/opendatahub-contrib/workbench-images:vscode-datascience-c9s-py311_2023c_latest -MAINTAINER Christopher Tate - ENV IJAVA_VERSION=1.3.0 \ JAVA_HOME=/usr/lib/jvm/java-17-openjdk USER root # Install pip dependencies -RUN pip install jupyter jupyterlab notebook ansible bash_kernel +RUN pip install \ + jupyter \ + jupyterlab \ + notebook \ + ansible \ + bash_kernel RUN python -m bash_kernel.install # Install IJava Kernel WORKDIR /usr/local/opt/ijava diff --git a/cluster-scope/base/image.openshift.io/imagestreams/vscode-java/imagestream.yaml b/cluster-scope/base/image.openshift.io/imagestreams/vscode-java/imagestream.yaml new file mode 100644 index 0000000..08b7ada --- /dev/null +++ b/cluster-scope/base/image.openshift.io/imagestreams/vscode-java/imagestream.yaml @@ -0,0 +1,29 @@ +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + name: vscode-java + namespace: redhat-ods-applications + labels: + opendatahub.io/notebook-image: "true" + annotations: + opendatahub.io/notebook-image-url: "https://github.com/computate-org/vscode-java" + opendatahub.io/notebook-image-name: "VSCode IJava java-17-openjdk" + opendatahub.io/notebook-image-desc: |- + An OpenShift AI Image for Java development. + Based on IJava project by SpencerPark on GitHub for Jupyter Lab Notebook integration. + Uses java-17-openjdk-devel and maven package support. + Used by the Smarta Byar Smart Village Community using AI/ML code generation technology for Smart Data Model APIs. +spec: + lookupPolicy: + local: true + tags: + - name: latest + annotations: null + from: + kind: DockerImage + name: 'ghcr.io/nerc-images/vscode-java:main' + importPolicy: + scheduled: true + referencePolicy: + type: Source +