Skip to content

Commit 102f5a6

Browse files
authored
Build contributed recipes in PRs (#2212)
* Build contributed recipes in PRs * Fix GitHub matrix
1 parent ae572aa commit 102f5a6

14 files changed

+60
-24
lines changed

.github/workflows/contributed-recipes.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ jobs:
4343
- name: Checkout Repo ⚡️
4444
uses: actions/checkout@v4
4545

46+
- name: Load image to Docker 📥
47+
if: ${{ github.event_name == 'workflow_call' && matrix.parent-image != '' }}
48+
uses: ./.github/actions/load-image
49+
with:
50+
image: ${{ matrix.parent-image }}
51+
platform: ${{ matrix.platform }}
52+
variant: default
53+
54+
# Not pulling the image, because it might be loaded from previous step or will be downloaded automatically
4655
- name: Build recipe 🛠
47-
run: docker build --pull --rm --force-rm --tag my-custom-image -f ./${{ matrix.dockerfile }} ./
56+
run: docker build --rm --force-rm --tag my-custom-image -f ./${{ matrix.dockerfile }} ./
4857
env:
4958
DOCKER_BUILDKIT: 1
5059
# Full logs for CI build

docs/using/recipe_code/custom_environment.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM quay.io/jupyter/minimal-notebook
1+
ARG BASE_IMAGE=quay.io/jupyter/minimal-notebook
2+
FROM $BASE_IMAGE
23

34
# Name your environment and choose the Python version
45
ARG env_name=python310

docs/using/recipe_code/dask_jupyterlab.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM quay.io/jupyter/base-notebook
1+
ARG BASE_IMAGE=quay.io/jupyter/base-notebook
2+
FROM $BASE_IMAGE
23

34
# Install the Dask dashboard
45
RUN mamba install --yes 'dask-labextension' && \

docs/using/recipe_code/generate_matrix.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,39 @@
22
# Copyright (c) Jupyter Development Team.
33
# Distributed under the terms of the Modified BSD License.
44
import json
5-
import os
65
from pathlib import Path
76
from typing import Any
87

98
THIS_DIR = Path(__file__).parent.resolve()
10-
REPOSITORY_OWNER = os.environ["REPOSITORY_OWNER"]
119

1210

13-
def generate_matrix() -> dict[str, Any]:
14-
dockerfiles = sorted(file.name for file in THIS_DIR.glob("*.dockerfile"))
11+
def generate_matrix() -> Any:
12+
dockerfiles = sorted(THIS_DIR.glob("*.dockerfile"))
1513
runs_on = ["ubuntu-24.04", "ubuntu-22.04-arm"]
16-
return {
17-
"dockerfile": dockerfiles,
18-
"runs-on": runs_on,
19-
"exclude": [
20-
{"dockerfile": "oracledb.dockerfile", "runs-on": "ubuntu-22.04-arm"}
21-
],
22-
}
14+
15+
configurations = []
16+
for dockerfile in dockerfiles:
17+
dockerfile_name = dockerfile.name
18+
for run in runs_on:
19+
if dockerfile_name == "oracledb.dockerfile" and run == "ubuntu-22.04-arm":
20+
continue
21+
dockerfile_lines = dockerfile.read_text().splitlines()
22+
base_image = [
23+
line for line in dockerfile_lines if line.startswith("ARG BASE_IMAGE=")
24+
][0][15:]
25+
base_image_short = base_image[base_image.rfind("/") + 1 :]
26+
# Handling a case of `docker.io/jupyter/base-notebook:notebook-6.5.4` image
27+
if ":" in base_image_short:
28+
base_image_short = ""
29+
configurations.append(
30+
{
31+
"dockerfile": dockerfile_name,
32+
"runs-on": run,
33+
"platform": "x86_64" if run == "ubuntu-24.04" else "aarch64",
34+
"parent-image": base_image_short,
35+
}
36+
)
37+
return {"include": configurations}
2338

2439

2540
if __name__ == "__main__":

docs/using/recipe_code/ijavascript.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM quay.io/jupyter/base-notebook
1+
ARG BASE_IMAGE=quay.io/jupyter/base-notebook
2+
FROM $BASE_IMAGE
23

34
USER root
45

docs/using/recipe_code/jupyterhub_version.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM quay.io/jupyter/base-notebook
1+
ARG BASE_IMAGE=quay.io/jupyter/base-notebook
2+
FROM $BASE_IMAGE
23

34
RUN mamba install --yes 'jupyterhub-singleuser==4.0.1' && \
45
mamba clean --all -f -y && \

docs/using/recipe_code/mamba_install.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM quay.io/jupyter/base-notebook
1+
ARG BASE_IMAGE=quay.io/jupyter/base-notebook
2+
FROM $BASE_IMAGE
23

34
RUN mamba install --yes 'flake8' && \
45
mamba clean --all -f -y && \

docs/using/recipe_code/manpage_install.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM quay.io/jupyter/base-notebook
1+
ARG BASE_IMAGE=quay.io/jupyter/base-notebook
2+
FROM $BASE_IMAGE
23

34
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
45
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014

docs/using/recipe_code/microsoft_odbc.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM quay.io/jupyter/base-notebook
1+
ARG BASE_IMAGE=quay.io/jupyter/base-notebook
2+
FROM $BASE_IMAGE
23

34
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
45
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014

docs/using/recipe_code/oracledb.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM quay.io/jupyter/base-notebook
1+
ARG BASE_IMAGE=quay.io/jupyter/base-notebook
2+
FROM $BASE_IMAGE
23

34
USER root
45

0 commit comments

Comments
 (0)