Skip to content

Commit 4958aa8

Browse files
committed
chore: add docker containers for jupyterhub and daskhub
1 parent 943cd5d commit 4958aa8

File tree

11 files changed

+244
-10
lines changed

11 files changed

+244
-10
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
name: Build and push Docker Images
3+
run-name: Build and push Docker Images for ${{ github.sha }} on ${{ github.ref }}
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
version:
9+
description: 'Which version of the Docker image should be built?'
10+
required: true
11+
type: string
12+
publish:
13+
description: 'Should the Docker image be published to the registry?'
14+
required: true
15+
type: boolean
16+
17+
env:
18+
REGISTRY: ghcr.io
19+
IMAGE: ghcr.io/3dct/image-quality-notebook
20+
AUTHORS: Lukas Behammer, lukas.behammer@fh-wels.at
21+
LICENSES: GPL-3.0-or-later
22+
URL: https://github.com/3dct/vIQA
23+
24+
jobs:
25+
build-and-push-image:
26+
runs-on: ubuntu-latest
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- dockerfile: ./containers/dh-image-quality-notebook/Dockerfile
32+
title: volumetric Image Quality Assessment Notebook - Daskhub
33+
description: This is a custom image for volumetric image quality assessment in daskhub.
34+
source: https://github.com/3dct/vIQA/tree/main/containers/dh-image-quality-notebook/Dockerfile
35+
documentation: https://github.com/3dct/vIQA/tree/main/containers/dh-image-quality-notebook/README.md
36+
prefix: dh
37+
- dockerfile: ./containers/jh-image-quality-notebook/Dockerfile
38+
title: volumetric Image Quality Assessment Notebook - JupyterHub
39+
description: This is a custom image for volumetric image quality assessment in jupyterhub.
40+
source: https://github.com/3dct/vIQA/tree/main/containers/jh-image-quality-notebook/Dockerfile
41+
documentation: https://github.com/3dct/vIQA/tree/main/containers/jh-image-quality-notebook/README.md
42+
prefix: jh
43+
44+
permissions:
45+
contents: read
46+
packages: write
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
- name: Log in to the Container registry
52+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
53+
with:
54+
registry: ${{ env.REGISTRY }}
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
- name: Extract metadata (tags, labels) for Docker
58+
id: meta
59+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
60+
with:
61+
images: ${{ env.IMAGE }}
62+
tags: |
63+
type=pep440,pattern={{version}},value=${{ inputs.version }}
64+
type=pep440,pattern={{major}},value=${{ inputs.version }}
65+
type=pep440,pattern={{major}}.{{minor}},value=${{ inputs.version }}
66+
labels: |
67+
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
68+
org.opencontainers.image.title=${{ matrix.title }}
69+
org.opencontainers.image.description=${{ matrix.description }}
70+
org.opencontainers.image.source=${{ matrix.source }}
71+
org.opencontainers.image.documentation=${{ matrix.documentation }}
72+
org.opencontainers.image.authors=${{ env.AUTHORS }}
73+
org.opencontainers.image.licenses=${{ env.LICENSES }}
74+
org.opencontainers.image.url=${{ env.URL }}
75+
org.opencontainers.image.version=${{ inputs.version }}
76+
flavor: |
77+
latest=true
78+
prefix=${{ matrix.prefix }},onlatest=true
79+
- name: Build and push Docker image
80+
id: push
81+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
82+
if: ${{ inputs.publish }}
83+
with:
84+
context: .
85+
file: ${{ matrix.dockerfile }}
86+
push: true
87+
tags: ${{ steps.meta.outputs.tags }}
88+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/documentation.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ permissions:
2020
contents: write
2121

2222
jobs:
23-
Docs:
23+
docs:
24+
name: Build and deploy documentation
2425
runs-on: ubuntu-latest
2526
concurrency: Docs
2627
# if: |
@@ -41,7 +42,7 @@ jobs:
4142
pip install -r ./requirements/docs.txt piq scipy scikit-image matplotlib nibabel tqdm
4243
- name: Sphinx build
4344
run: |
44-
sphinx-build docs/source _build
45+
sphinx-build docs/source docs/build/html
4546
env:
4647
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4748
- name: Deploy to GitHub Pages
@@ -50,5 +51,5 @@ jobs:
5051
with:
5152
publish_branch: gh-pages
5253
github_token: ${{ secrets.GITHUB_TOKEN }}
53-
publish_dir: _build/
54+
publish_dir: docs/build/html
5455
force_orphan: true

.github/workflows/release.yaml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
src-changes: ${{ steps.changed-files.outputs.src_any_changed }}
2222
test-changes: ${{ steps.changed-files.outputs.tests_any_changed }}
2323
lint-changes: ${{ steps.changed-files.outputs.lint_any_changed }}
24+
docker-changes: ${{ steps.changed-files.outputs.docker_any_changed }}
2425

2526
steps:
2627
- uses: actions/checkout@v4
@@ -54,6 +55,11 @@ jobs:
5455
- src/**
5556
- notebooks/**
5657
- pyproject.toml
58+
docker:
59+
- .github/workflows/build_and_push_docker_images.yaml
60+
- containers/**
61+
- notebooks/**
62+
- src/**
5763
5864
- name: Detect if any of the combinations of file sets have changed
5965
id: all-changes
@@ -64,7 +70,8 @@ jobs:
6470
[ "${{ steps.changed-files.outputs.docs_any_changed }}" == "true" ] || \
6571
[ "${{ steps.changed-files.outputs.src_any_changed }}" == "true" ] || \
6672
[ "${{ steps.changed-files.outputs.tests_any_changed }}" == "true" ] || \
67-
[ "${{ steps.changed-files.outputs.lint_any_changed }}" == "true" ]; then
73+
[ "${{ steps.changed-files.outputs.lint_any_changed }}" == "true" ] || \
74+
[ "${{ steps.changed-files.outputs.docker_any_changed }}" == "true" ]; then
6875
printf '%s\n' "any_changed=true" >> $GITHUB_OUTPUT
6976
fi
7077
@@ -325,16 +332,18 @@ jobs:
325332
with:
326333
github_token: ${{ secrets.GITHUB_TOKEN }}
327334

328-
prepare_docs_input:
335+
prepare_publish_input:
329336
name: Check if published
330337
runs-on: ubuntu-latest
331-
if: needs.changes.outputs.doc-changes == 'true' && always()
338+
if: (needs.changes.outputs.doc-changes == 'true' || needs.changes.outputs.docker-changes == 'true') && always()
332339
outputs:
333-
publish: ${{ steps.check_publish.outputs.publish }}
340+
docs_publish: ${{ steps.check_docs_publish.outputs.publish }}
341+
image_publish: ${{ steps.check_image_publish.outputs.publish }}
334342
needs: [changes, upload_github, upload_pypi]
335343
steps:
336344
- name: Check if documentation should be published
337-
id: check_publish
345+
id: check_docs_publish
346+
if: needs.changes.outputs.doc-changes == 'true'
338347
run: |
339348
# If either the PyPI or GitHub release was successful, publish the docs
340349
if ${{ needs.upload_github.result == 'success' }} || ${{ needs.upload_pypi.result == 'success' }}; then
@@ -347,11 +356,28 @@ jobs:
347356
echo "publish=false" >> $GITHUB_OUTPUT
348357
fi
349358
fi
359+
- name: Check if Docker images should be published
360+
id: check_image_publish
361+
if: needs.changes.outputs.docker-changes == 'true'
362+
run: |
363+
# If either the PyPI or GitHub release was successful, publish the Docker images
364+
if ${{ needs.upload_github.result == 'success' }} || ${{ needs.upload_pypi.result == 'success' }}; then
365+
echo "publish=true" >> $GITHUB_OUTPUT
366+
fi
350367
351368
docs:
352369
name: Build and deploy documentation
353370
uses: ./.github/workflows/documentation.yaml
354-
needs: [changes, prepare_docs_input]
371+
needs: [changes, prepare_publish_input]
355372
if: github.repository == '3dct/viqa' && needs.changes.outputs.doc-changes == 'true'
356373
with:
357-
publish: ${{ needs.prepare_docs_input.outputs.publish }}
374+
publish: ${{ needs.prepare_publish_input.outputs.docs_publish }}
375+
376+
build_and_push_docker_images:
377+
name: Build and push Docker Images
378+
uses: ./.github/workflows/build_and_push_docker_images.yaml
379+
needs: [changes, semantic_release, prepare_publish_input]
380+
if: github.repository == '3dct/viqa' && needs.changes.outputs.docker-changes == 'true'
381+
with:
382+
version: ${{ needs.semantic_release.outputs.version }}
383+
publish: ${{ needs.prepare_publish_input.outputs.image_publish }}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ psnr.print_score(decimals=2)
229229
230230
For more examples, see the provided Jupyter notebooks and the documentation under [API Reference](https://3dct.github.io/vIQA/api_reference.html).
231231

232+
## Container Images
233+
Container images to use this package in a JupyterHub or Daskhub environment as a single user notebook can be found under [./containers](./containers).
234+
232235
<!-- ## Benchmark TODO: add benchmark results and instructions -->
233236

234237
## TODO
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# This is the config for the jupyter_app_launcher extension to launch the vIQA notebooks
3+
# The notebooks are available under https://github.com/3dct/vIQA/tree/master/Notebooks
4+
# and have to be copied to the shared folder which might have to be mounted to the
5+
# singleuser pod
6+
- title: vIQA Documentation
7+
description: Example of opening a URL in a tab
8+
source: https://3dct.github.io/vIQA/
9+
type: url
10+
args:
11+
sandbox:
12+
- 'allow-same-origin'
13+
- 'allow-scripts'
14+
- 'allow-downloads'
15+
- 'allow-modals'
16+
- 'allow-popups'
17+
referrerPolicy: ['no-referrer']
18+
createNewWindow: false
19+
catalog: vIQA
20+
21+
- title: vIQA Notebook
22+
description: vIQA template notebook
23+
source: /usr/share/jupyter/jupyter_app_launcher/notebooks/Image_Comparison.ipynb
24+
cwd: /usr/share/jupyter/jupyter_app_launcher/notebooks
25+
type: notebook
26+
catalog: vIQA
27+
28+
- title: vIQA batch Notebook
29+
description: vIQA template notebook for batch mode
30+
source: /usr/share/jupyter/jupyter_app_launcher/notebooks/Image_Comparison_batch.ipynb
31+
cwd: /usr/share/jupyter/jupyter_app_launcher/notebooks
32+
type: notebook
33+
catalog: vIQA
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Documentation
2+
README.md
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM pangeo/base-notebook:2024.01.15
2+
LABEL org.opencontainers.image.title="volumetric Image Quality Assessment Notebook - Daskhub"
3+
LABEL org.opencontainers.image.description="This is a custom image for volumetric image quality assessment in daskhub."
4+
LABEL org.opencontainers.image.authors="Lukas Behammer, lukas.behammer@fh-wels.at"
5+
LABEL org.opencontainers.image.source="https://github.com/3dct/vIQA/tree/main/containers/dh-image-quality-notebook/Dockerfile"
6+
LABEL org.opencontainers.image.documentation="https://github.com/3dct/vIQA/tree/main/containers/dh-image-quality-notebook/README.md"
7+
LABEL org.opencontainers.image.url="https://github.com/3dct/vIQA"
8+
LABEL org.opencontainers.image.licenses="GPL-3.0-or-later"
9+
10+
# install git
11+
USER root
12+
RUN apt-get update
13+
RUN apt-get install -y git-all
14+
15+
USER ${NB_UID}
16+
# install additional packages
17+
RUN pip install viqa
18+
RUN pip install jupyter_app_launcher
19+
RUN pip install jupyterlab-git
20+
21+
COPY notebooks /usr/share/jupyter/jupyter_app_launcher/notebooks
22+
COPY containers/config/jp_app_launcher/jp_app_launcher.yaml /usr/share/jupyter/jupyter_app_launcher/jp_app_launcher.yaml
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# volumetric Image Quality Assessment Notebook - Daskhub
2+
3+
[![Build GH Action](https://github.com/3dct/vIQA/actions/workflows/build_and_push_docker_images.yaml/badge.svg)](https://github.com/3dct/vIQA/actions/workflows/build_and_push_docker_images.yaml)
4+
[![latest](https://ghcr-badge.egpl.dev/3dct/image-quality-notebook/latest_tag?label=latest&ignore=dh-*)](https://github.com/3dct/vIQA/pkgs/container/image-quality-notebook)
5+
[![tags](https://ghcr-badge.egpl.dev/3dct/image-quality-notebook/tags?n=3&ignore=jh-*)](https://github.com/3dct/vIQA/pkgs/container/image-quality-notebook)
6+
[![image size](https://ghcr-badge.egpl.dev/3dct/image-quality-notebook/size?tag=dh-latest)](https://github.com/3dct/vIQA/pkgs/container/image-quality-notebook)
7+
8+
9+
This is a single user notebook for volumetric Image Quality Assessment (vIQA) to be used with Daskhub.
10+
11+
## Base Image
12+
[pangeo/base-notebook:2024.01.15](https://github.com/pangeo-data/pangeo-docker-images)
13+
14+
## Additionally Installed Packages
15+
| Package | Tools | JupyterLab Extensions |
16+
|---------|-------|-----------------------|
17+
| viqa | git | jupyterlab-git |
18+
| | | jupyter_app_launcher |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Documentation
2+
README.md
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM quay.io/jupyter/base-notebook:python-3.12
2+
LABEL org.opencontainers.image.title="volumetric Image Quality Assessment Notebook - JupyterHub"
3+
LABEL org.opencontainers.image.description="This is a custom image for volumetric image quality assessment in jupyterhub."
4+
LABEL org.opencontainers.image.authors="Lukas Behammer, lukas.behammer@fh-wels.at"
5+
LABEL org.opencontainers.image.source="https://github.com/3dct/vIQA/tree/main/containers/jh-image-quality-notebook/Dockerfile"
6+
LABEL org.opencontainers.image.documentation="https://github.com/3dct/vIQA/tree/main/containers/jh-image-quality-notebook/README.md"
7+
LABEL org.opencontainers.image.url="https://github.com/3dct/vIQA"
8+
LABEL org.opencontainers.image.licenses="GPL-3.0-or-later"
9+
10+
# install git
11+
USER root
12+
RUN apt-get update
13+
RUN apt-get install -y git-all
14+
15+
USER ${NB_UID}
16+
# install additional packages
17+
RUN pip install viqa
18+
RUN pip install jupyter_app_launcher
19+
RUN pip install jupyterlab-git
20+
21+
COPY notebooks /usr/share/jupyter/jupyter_app_launcher/notebooks
22+
COPY containers/config/jp_app_launcher/jp_app_launcher.yaml /usr/share/jupyter/jupyter_app_launcher/jp_app_launcher.yaml

0 commit comments

Comments
 (0)