Skip to content

Commit

Permalink
Introducing support for R2023b. Default OS updated to ubuntu22.04. Do…
Browse files Browse the repository at this point in the history
…ckerfiles for ubuntu20.04 are moved to a new sub-folder.
  • Loading branch information
Prabhakar Kumar committed Dec 6, 2023
1 parent 2c25c56 commit ac64aa7
Show file tree
Hide file tree
Showing 28 changed files with 1,378 additions and 346 deletions.
22 changes: 0 additions & 22 deletions .github/actions/build-and-push-notebook/action.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Workflows in matlab-integration-for-jupyter

This repository uses workflows to build the Dockerfiles hosted in this repository and publish them to GHCR.

## Overview

There are 2 kinds of YML files used here:
1. `build-and-publish-docker-image.yml`, which specifies a reusable workflow, which MUST be called from a workflow configuration file.
2. Other YML files in the `.github/workflows` directory call this reusable-workflow.

Each of these workflows:
a. Monitors a specific Dockerfile. For example, the file `matlab-ubuntu20.04-mounted-dockerfile.yml` monitors the Dockerfile `matlab/ubuntu20.04/Dockerfile.mounted`
b. Is triggered when changes are made to the Dockerfile it monitors. This should build and publish to the configured registries.

## Triggers and Scheduled Jobs

All workflows are scheduled to run on Monday at 00:00.
Workflows are also triggered when you push any changes to the directories with Dockerfiles.
Workflows can be manually triggered from the "Actions" tab.

## Directory structure

The matlab-integration-for-jupyter repository has the following folder structure:

1. matlab : Hosts the Dockerfile that showcase access to matlab through the `jupyter-matlab-proxy` package.
* matlab/ubuntu20.04 : Hosts the same dockerfiles but with support for `ubuntu20.04`
1. matlab-vnc : Hosts the Dockerfile that showcase access to matlab through the `jupyter-matlab-vnc-proxy` package.
* matlab-vnc/ubuntu20.04 : Hosts the same dockerfiles but with support for `ubuntu20.04`

## Images Pushed to GHCR:

| Name of Dockerfile | Name of Image Pushed | Tags Available |
|----|----|----|
|matlab/Dockerfile | jupyter-matlab-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 |
|matlab/Dockerfile.byoi | jupyter-byoi-matlab-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 |
|matlab/Dockerfile.mounted | jupyter-mounted-matlab-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 |
|matlab/ubuntu20.04/Dockerfile | jupyter-matlab-notebook | r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 |
|matlab/ubuntu20.04/Dockerfile.byoi | jupyter-byoi-matlab-notebook | r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 |
|matlab/ubuntu20.04/Dockerfile.mounted | jupyter-mounted-matlab-notebook |r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 |
|matlab-vnc/Dockerfile | jupyter-matlab-vnc-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 |
|matlab-vnc/Dockerfile.mounted | jupyter-mounted-matlab-vnc-notebook | r2023b, r2023a, r2022b, r2023b-ubuntu22.04, r2023a-ubuntu22.04, r2022b-ubuntu22.04 |
|matlab-vnc/ubuntu20.04/Dockerfile | jupyter-matlab-vnc-notebook | r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 |
|matlab-vnc/ubuntu20.04/Dockerfile.mounted | jupyter-mounted-matlab-vnc-notebook | r2023b-ubuntu20.04, r2023a-ubuntu20.04, r2020b-ubuntu20.04, r2020a-ubuntu20.04, r2021b-ubuntu20.04, r2021a-ubuntu20.04, r2020b-ubuntu20.04 |

Note: Pascal cased tags are also made available. ie: r2023a-ubuntu20.04 will also have a `R`2023a-ubuntu20.04

Each `reusable-workflow` job consists of the following steps:

1. Check-out the repository into a GitHub Actions runner.
1. Setup Image Tags: Configures tags to have both Pascal & camel case tags (R2023a, r2023a)
1. Login to DockerHub Container Registry
1. Build the image & push
1. If the variable "should_add_latest_tag" is present that an additional "latest" tag is added to the image.

----
Copyright 2023 The MathWorks, Inc.
----
98 changes: 98 additions & 0 deletions .github/workflows/build-and-publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Copyright 2023 The MathWorks, Inc.

name: Build and Publish the Container Image

# images build with this workflow are created with the following naming conventions:
# ${base_image_name}:${matlab_release}-${os}

# built images are pushed to DockerHub. Note: Both camel & Pascal case versions of tags are generated and published

# This workflow is only be triggered when called from another workflow.
on:
workflow_call:
inputs:
docker_build_context:
description: 'Relative path to folder with Dockerfile. Ex: ./matlab'
required: true
type: string
base_image_name:
description: 'Fully qualified name of image name'
required: true
type: string
matlab_release_tag:
description: 'Name of matlab release. Example: r2023a'
required: true
type: string
os_info_tag:
description: 'Allowed values: ubuntu20.04 ubuntu22.04'
required: true
type: string
is_default_os:
description: 'If true, then an additional tag without OS information is generated.'
required: true
type: boolean

jobs:
build-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name : Setup Image Tags
id: setup_image_tags
run: |
RAW_MATLAB_RELEASE=${{ inputs.matlab_release_tag }} \
&& LOWER_CASE_MATLAB_RELEASE=${RAW_MATLAB_RELEASE,,} \
&& echo "TAG_RELEASE_ONLY_CAMEL_CASE=${LOWER_CASE_MATLAB_RELEASE}" >> "$GITHUB_OUTPUT" \
&& echo "TAG_RELEASE_ONLY_PASCAL_CASE=${LOWER_CASE_MATLAB_RELEASE^}" >> "$GITHUB_OUTPUT" \
&& echo "TAG_RELEASE_AND_OS_CAMEL_CASE=${LOWER_CASE_MATLAB_RELEASE}-${{ inputs.os_info_tag }}" >> "$GITHUB_OUTPUT" \
&& echo "TAG_RELEASE_AND_OS_PASCAL_CASE=${LOWER_CASE_MATLAB_RELEASE^}-${{ inputs.os_info_tag }}" >> "$GITHUB_OUTPUT"
# See here for example: https://docs.docker.com/build/ci/github-actions/push-multi-registries/
# -
# name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Example tags: r2023a-ubuntu20.04, R2023a-ubuntu20.04
- name: Build & Push Image
if: ${{ inputs.is_default_os == false }}
uses: docker/build-push-action@v4
with:
context: ${{ inputs.docker_build_context }}
platforms: linux/amd64
push: true
tags: |
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_CAMEL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_PASCAL_CASE }}
build-args: MATLAB_RELEASE=${{ inputs.matlab_release_tag }}

# Example tags: r2023a-ubuntu20.04, R2023a-ubuntu20.04, r2023a, R2023a
- name: Build & Push Image for latest OS
if: ${{ inputs.is_default_os == true }}
uses: docker/build-push-action@v4
with:
context: ${{ inputs.docker_build_context }}
platforms: linux/amd64
push: true
tags: |
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_ONLY_CAMEL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_ONLY_PASCAL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_CAMEL_CASE }}
${{ inputs.base_image_name }}:${{ steps.setup_image_tags.outputs.TAG_RELEASE_AND_OS_PASCAL_CASE }}
build-args: MATLAB_RELEASE=${{ inputs.matlab_release_tag }}


69 changes: 0 additions & 69 deletions .github/workflows/build-and-publish-dockerfiles.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/matlab-byoi-dockerfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab/Dockerfile.byoi
name: matlab/Dockerfile.byoi

# Define when builds will occur:
on:
# Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path
push:
branches:
- 'main'
paths:
- 'matlab/Dockerfile.byoi'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
- cron: '0 0 * * 1'

workflow_dispatch:

jobs:
build-and-publish-docker-image:
strategy:
fail-fast: false
matrix:
matlab_release_tag: [r2023b, r2023a, r2022b]
uses: ./.github/workflows/build-and-publish-docker-image.yml
secrets: inherit
with:
docker_build_context: './matlab'
base_image_name: ghcr.io/${{ github.repository }}/jupyter-byoi-matlab-notebook
os_info_tag: 'ubuntu22.04'
matlab_release_tag: ${{ matrix.matlab_release_tag }}
is_default_os: true
33 changes: 33 additions & 0 deletions .github/workflows/matlab-dockerfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab/Dockerfile
name: matlab/Dockerfile

# Define when builds will occur:
on:
# Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path
push:
branches:
- 'main'
paths:
- 'matlab/Dockerfile'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
- cron: '0 0 * * 1'

workflow_dispatch:

jobs:
build-and-publish-docker-image:
strategy:
fail-fast: false
matrix:
matlab_release_tag: [r2023b, r2023a, r2022b]
uses: ./.github/workflows/build-and-publish-docker-image.yml
secrets: inherit
with:
docker_build_context: './matlab'
base_image_name: ghcr.io/${{ github.repository }}/jupyter-matlab-notebook
os_info_tag: 'ubuntu22.04'
matlab_release_tag: ${{ matrix.matlab_release_tag }}
is_default_os: true
33 changes: 33 additions & 0 deletions .github/workflows/matlab-mounted-dockerfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab/Dockerfile.mounted
name: matlab/Dockerfile.mounted

# Define when builds will occur:
on:
# Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path
push:
branches:
- 'main'
paths:
- 'matlab/Dockerfile.mounted'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
- cron: '0 0 * * 1'

workflow_dispatch:

jobs:
build-and-publish-docker-image:
strategy:
fail-fast: false
matrix:
matlab_release_tag: [r2023b, r2023a, r2022b]
uses: ./.github/workflows/build-and-publish-docker-image.yml
secrets: inherit
with:
docker_build_context: './matlab'
base_image_name: ghcr.io/${{ github.repository }}/jupyter-mounted-matlab-notebook
os_info_tag: 'ubuntu22.04'
matlab_release_tag: ${{ matrix.matlab_release_tag }}
is_default_os: true
33 changes: 33 additions & 0 deletions .github/workflows/matlab-ubuntu20.04-byoi-dockerfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 The MathWorks, Inc.
# Build & Publish matlab/ubuntu20.04/Dockerfile.byoi
name: matlab/ubuntu20.04/Dockerfile.byoi

# Define when builds will occur:
on:
# Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path
push:
branches:
- 'main'
paths:
- 'matlab/ubuntu20.04/Dockerfile.byoi'

# Run at 00:00 on every Monday (1st Day of the Week) (See: crontab.guru)
schedule:
- cron: '0 0 * * 1'

workflow_dispatch:

jobs:
build-and-publish-docker-image:
strategy:
fail-fast: false
matrix:
matlab_release_tag: [r2023b, r2023a, r2022b, r2022a, r2021b, r2021a, r2020b]
uses: ./.github/workflows/build-and-publish-docker-image.yml
secrets: inherit
with:
docker_build_context: './matlab/ubuntu20.04'
base_image_name: ghcr.io/${{ github.repository }}/jupyter-byoi-matlab-notebook
os_info_tag: 'ubuntu20.04'
matlab_release_tag: ${{ matrix.matlab_release_tag }}
is_default_os: false
Loading

0 comments on commit ac64aa7

Please sign in to comment.