<!-- Thank you for contributing to Pyodide! All improvements are welcome,
     so don't be afraid to make a PR. -->

<!-- [IMPORTANT] Note on CI failures:
     Currently, we are having issues with selenium-based tests.
     Don't panic if the CI fails on your PR because of timeouts.
     It's probably not your fault. We will investigate :) -->

### Description

<!-- Please explain what your PR is about:
     - reasoning for the change
     - some details of updated code
     - any noteworthy choices to be aware of
	Please refer to any related issues by #<issue_id> -->

Bumping MPL version - it turns out that Hist (which uses boost-histogram) depends on mplhep, which in turn requires matplotlib 3.4+. So I migrated the patches and bumped MPL.

I noticed micropip doesn't seem to respect extras, that is, `await micropip.install("hist[plot]")` doesn't seem to work. (will investigate later)

* Updated matplotlib to 3.5
    * Added fonttools
* Updated yt to 4
    * Added `cmyt` and `unyt`, which I am pretty sure are yt specific. At least by looking at the name. 😆 
    * Also `colorspacious`
    * Also `tdqm`
    * Also `tomli` and `tomli-w` (backported from the next yt release to avoid adding a dead dependency `toml`)

Closes #2088 too. Also 3.5 was the first version to officially support 3.10, I think.
chore: matplotlib 3.5.1, yt 4. <!-- Thank you for contributing to Pyodide! All improvements are welcome,
     so don't be afraid to make a PR. -->

<!-- [IMPORTANT] Note on CI failures:
     Currently, we are having issues with selenium-based tests.
     Don't panic if the CI fails on your PR because of timeouts.
     It's probably not your fault. We will investigate :) -->

### Description

<!-- Please explain what your PR is about:
     - reasoning for the change
     - some details of updated code
     - any noteworthy choices to be aware of
	Please refer to any related issues by #<issue_id> -->

Bumping MPL version - it turns out that Hist (which uses boost-histogram) depends on mplhep, which in turn requires matplotlib 3.4+. So I migrated the patches and bumped MPL.

I noticed micropip doesn't seem to respect extras, that is, `await micropip.install("hist[plot]")` doesn't seem to work. (will investigate later)

* Updated matplotlib to 3.5
    * Added fonttools
* Updated yt to 4
    * Added `cmyt` and `unyt`, which I am pretty sure are yt specific. At least by looking at the name. 😆 
    * Also `colorspacious`
    * Also `tdqm`
    * Also `tomli` and `tomli-w` (backported from the next yt release to avoid adding a dead dependency `toml`)

Closes #2088 too. Also 3.5 was the first version to officially support 3.10, I think.
name: pyodide-env-docker
on:
  workflow_dispatch:
    inputs:
      chrome_version:
        description: "Version of the chrome browser (e.g. 97, 96, latest)."
        required: false
        default: "97"
      firefox_version:
        description: "Version of the firefox browser (e.g. 96, 95, latest)."
        required: false
        default: "96"
      tag:
        description: "Tag of the docker image to build (If not set, <release-date>-chrome[version]-firefox[version] will be used)"
        required: false
        default: ""
env:
  GHCR_REGISTRY: ghcr.io
  IMAGE_NAME: pyodide/pyodide-env
jobs:
  build_docker:
    runs-on: ubuntu-latest
    environment: Docker
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Log into Docker Hub registry
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.IMAGE_NAME }}
      - name: Set tag
        id: tag
        run: |
          TAG=${{ github.event.inputs.tag }}
          if [ -z "$TAG" ]; then
            DATE=$(date +'%Y%m%d')
            TAG="$DATE-chrome${{ github.event.inputs.chrome_version }}-firefox${{ github.event.inputs.firefox_version }}"
          fi
          echo "::set-output name=tag::$TAG"
      - name: Build and push Docker image to Docker Hub
        id: build
        uses: docker/build-push-action@v2
        with:
          file: ./Dockerfile
          push: true
          tags: ${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            CHROME_VERSION=${{ github.event.inputs.chrome_version }}
            FIREFOX_VERSION=${{ github.event.inputs.firefox_version }}
      - name: Image digest
        run: echo ${{ steps.build.outputs.digest }}
  build_ghcr:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Log into registry ${{ env.GHCR_REGISTRY }}
        uses: docker/login-action@v1
        with:
          registry: ${{ env.GHCR_REGISTRY }}
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
      - name: Set tag
        id: tag
        run: |
          TAG=${{ github.event.inputs.tag }}
          if [ -z "$TAG" ]; then
            DATE=$(date +'%Y%m%d')
            TAG="$DATE-chrome${{ github.event.inputs.chrome_version }}-firefox${{ github.event.inputs.firefox_version }}"
          fi
          echo "::set-output name=tag::$TAG"
      - name: Build and push Docker image to ${{ env.GHCR_REGISTRY }}
        id: build
        uses: docker/build-push-action@v2
        with:
          file: ./Dockerfile
          push: true
          tags: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            CHROME_VERSION=${{ github.event.inputs.chrome_version }}
            FIREFOX_VERSION=${{ github.event.inputs.firefox_version }}
      - name: Image digest
        run: echo ${{ steps.build.outputs.digest }}

name: pyodide-env-docker
on:
  workflow_dispatch:
    inputs:
      chrome_version:
        description: "Version of the chrome browser (e.g. 97, 96, latest)."
        required: false
        default: "97"
      firefox_version:
        description: "Version of the firefox browser (e.g. 96, 95, latest)."
        required: false
        default: "96"
      tag:
        description: "Tag of the docker image to build (If not set, <release-date>-chrome[version]-firefox[version] will be used)"
        required: false
        default: ""
env:
  GHCR_REGISTRY: ghcr.io
  IMAGE_NAME: pyodide/pyodide-env
jobs:
  build_docker:
    runs-on: ubuntu-latest
    environment: Docker
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Log into Docker Hub registry
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.IMAGE_NAME }}
      - name: Set tag
        id: tag
        run: |
          TAG=${{ github.event.inputs.tag }}
          if [ -z "$TAG" ]; then
            DATE=$(date +'%Y%m%d')
            TAG="$DATE-chrome${{ github.event.inputs.chrome_version }}-firefox${{ github.event.inputs.firefox_version }}"
          fi
          echo "::set-output name=tag::$TAG"
      - name: Build and push Docker image to Docker Hub
        id: build
        uses: docker/build-push-action@v2
        with:
          file: ./Dockerfile
          push: true
          tags: ${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            CHROME_VERSION=${{ github.event.inputs.chrome_version }}
            FIREFOX_VERSION=${{ github.event.inputs.firefox_version }}
      - name: Image digest
        run: echo ${{ steps.build.outputs.digest }}
  build_ghcr:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Log into registry ${{ env.GHCR_REGISTRY }}
        uses: docker/login-action@v1
        with:
          registry: ${{ env.GHCR_REGISTRY }}
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
      - name: Set tag
        id: tag
        run: |
          TAG=${{ github.event.inputs.tag }}
          if [ -z "$TAG" ]; then
            DATE=$(date +'%Y%m%d')
            TAG="$DATE-chrome${{ github.event.inputs.chrome_version }}-firefox${{ github.event.inputs.firefox_version }}"
          fi
          echo "::set-output name=tag::$TAG"
      - name: Build and push Docker image to ${{ env.GHCR_REGISTRY }}
        id: build
        uses: docker/build-push-action@v2
        with:
          file: ./Dockerfile
          push: true
          tags: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            CHROME_VERSION=${{ github.event.inputs.chrome_version }}
            FIREFOX_VERSION=${{ github.event.inputs.firefox_version }}
      - name: Image digest
        run: echo ${{ steps.build.outputs.digest }}
