Skip to content

Commit f8cd90a

Browse files
authored
Add an ability to specify registry when using docker images (#2008)
* Add an ability to specify registry when using docker images * Fix typo * [TMP] Speedup workflow * Revert "[TMP] Speedup workflow" This reverts commit 3af0055.
1 parent bceaead commit f8cd90a

33 files changed

+119
-56
lines changed

.github/workflows/docker-build-test-upload.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Download parent image, build a new one and test it; then upload the image, tags and manifests to GitHub artifacts
22

33
env:
4+
REGISTRY: docker.io
45
OWNER: ${{ github.repository_owner }}
56

67
on:
@@ -60,20 +61,20 @@ jobs:
6061
shell: bash
6162

6263
- name: Build image 🛠
63-
run: docker build --rm --force-rm --tag ${{ env.OWNER }}/${{ inputs.image }} images/${{ inputs.image }}/ --build-arg OWNER=${{ env.OWNER }}
64+
run: docker build --rm --force-rm --tag ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ inputs.image }} images/${{ inputs.image }}/ --build-arg REGISTRY=${{ env.REGISTRY }} --build-arg OWNER=${{ env.OWNER }}
6465
env:
6566
DOCKER_BUILDKIT: 1
6667
# Full logs for CI build
6768
BUILDKIT_PROGRESS: plain
6869
shell: bash
6970

7071
- name: Run tests ✅
71-
run: python3 -m tests.run_tests --short-image-name ${{ inputs.image }} --owner ${{ env.OWNER }}
72+
run: python3 -m tests.run_tests --short-image-name ${{ inputs.image }} --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }}
7273
shell: bash
7374

7475
- name: Write tags file 🏷
7576
run: |
76-
python3 -m tagging.write_tags_file --short-image-name ${{ inputs.image }} --tags-dir /tmp/jupyter/tags/ --owner ${{ env.OWNER }}
77+
python3 -m tagging.write_tags_file --short-image-name ${{ inputs.image }} --tags-dir /tmp/jupyter/tags/ --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }}
7778
shell: bash
7879
- name: Upload tags file 💾
7980
uses: actions/upload-artifact@v3
@@ -83,7 +84,7 @@ jobs:
8384
retention-days: 3
8485

8586
- name: Write manifest and build history file 🏷
86-
run: python3 -m tagging.write_manifest --short-image-name ${{ inputs.image }} --hist-line-dir /tmp/jupyter/hist_lines/ --manifest-dir /tmp/jupyter/manifests/ --owner ${{ env.OWNER }}
87+
run: python3 -m tagging.write_manifest --short-image-name ${{ inputs.image }} --hist-line-dir /tmp/jupyter/hist_lines/ --manifest-dir /tmp/jupyter/manifests/ --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }}
8788
shell: bash
8889
- name: Upload manifest file 💾
8990
uses: actions/upload-artifact@v3

.github/workflows/docker-tag-push.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Download Docker image and its tags from GitHub artifacts, apply them and push the image to Docker Hub
22

33
env:
4+
REGISTRY: docker.io
45
OWNER: ${{ github.repository_owner }}
56

67
on:
@@ -50,7 +51,7 @@ jobs:
5051
name: ${{ inputs.image }}-${{ inputs.platform }}-tags
5152
path: /tmp/jupyter/tags/
5253
- name: Apply tags to the loaded image 🏷
53-
run: python3 -m tagging.apply_tags --short-image-name ${{ inputs.image }} --tags-dir /tmp/jupyter/tags/ --platform ${{ inputs.platform }} --owner ${{ env.OWNER }}
54+
run: python3 -m tagging.apply_tags --short-image-name ${{ inputs.image }} --tags-dir /tmp/jupyter/tags/ --platform ${{ inputs.platform }} --registry ${{ env.REGISTRY }} --owner ${{ env.OWNER }}
5455

5556
- name: Push Images to Docker Hub 📤
5657
if: github.repository == 'jupyter/docker-stacks' && (github.ref == 'refs/heads/main' || github.event_name == 'schedule')

Makefile

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Use bash for inline if-statements in arch_patch target
66
SHELL:=bash
7+
REGISTRY?=docker.io
78
OWNER?=jupyter
89

910
# Need to list the images in build dependency order
@@ -37,9 +38,9 @@ help:
3738

3839
build/%: DOCKER_BUILD_ARGS?=
3940
build/%: ## build the latest image for a stack using the system's architecture
40-
docker build $(DOCKER_BUILD_ARGS) --rm --force-rm --tag "$(OWNER)/$(notdir $@):latest" "./images/$(notdir $@)" --build-arg OWNER="$(OWNER)"
41+
docker build $(DOCKER_BUILD_ARGS) --rm --force-rm --tag "$(REGISTRY)/$(OWNER)/$(notdir $@):latest" "./images/$(notdir $@)" --build-arg REGISTRY="$(REGISTRY)" --build-arg OWNER="$(OWNER)"
4142
@echo -n "Built image size: "
42-
@docker images "$(OWNER)/$(notdir $@):latest" --format "{{.Size}}"
43+
@docker images "$(REGISTRY)/$(OWNER)/$(notdir $@):latest" --format "{{.Size}}"
4344
build-all: $(foreach I, $(ALL_IMAGES), build/$(I)) ## build all stacks
4445

4546

@@ -68,9 +69,9 @@ linkcheck-docs: ## check broken links
6869

6970

7071
hook/%: ## run post-build hooks for an image
71-
python3 -m tagging.write_tags_file --short-image-name "$(notdir $@)" --tags-dir /tmp/jupyter/tags/ --owner "$(OWNER)" && \
72-
python3 -m tagging.write_manifest --short-image-name "$(notdir $@)" --hist-line-dir /tmp/jupyter/hist_lines/ --manifest-dir /tmp/jupyter/manifests/ --owner "$(OWNER)" && \
73-
python3 -m tagging.apply_tags --short-image-name "$(notdir $@)" --tags-dir /tmp/jupyter/tags/ --platform "$(shell uname -m)" --owner "$(OWNER)"
72+
python3 -m tagging.write_tags_file --short-image-name "$(notdir $@)" --tags-dir /tmp/jupyter/tags/ --registry "$(REGISTRY)" --owner "$(OWNER)" && \
73+
python3 -m tagging.write_manifest --short-image-name "$(notdir $@)" --hist-line-dir /tmp/jupyter/hist_lines/ --manifest-dir /tmp/jupyter/manifests/ --registry "$(REGISTRY)" --owner "$(OWNER)" && \
74+
python3 -m tagging.apply_tags --short-image-name "$(notdir $@)" --tags-dir /tmp/jupyter/tags/ --platform "$(shell uname -m)" --registry "$(REGISTRY)" --owner "$(OWNER)"
7475
hook-all: $(foreach I, $(ALL_IMAGES), hook/$(I)) ## run post-build hooks for all images
7576

7677

@@ -105,5 +106,5 @@ run-sudo-shell/%: ## run a bash in interactive mode as root in a stack
105106

106107

107108
test/%: ## run tests against a stack
108-
python3 -m tests.run_tests --short-image-name "$(notdir $@)" --owner "$(OWNER)"
109+
python3 -m tests.run_tests --short-image-name "$(notdir $@)" --registry "$(REGISTRY)" --owner "$(OWNER)"
109110
test-all: $(foreach I, $(ALL_IMAGES), test/$(I)) ## test all stacks

binder/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# Distributed under the terms of the Modified BSD License.
33

44
# https://hub.docker.com/r/jupyter/base-notebook/tags
5+
ARG REGISTRY=docker.io
56
ARG OWNER=jupyter
6-
ARG BASE_CONTAINER=$OWNER/base-notebook:2023-09-25
7+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/base-notebook:2023-09-25
78
FROM $BASE_CONTAINER
89

910
LABEL maintainer="Jupyter Project <[email protected]>"

docs/using/recipe_code/custom_environment.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
# Name your environment and choose the python version
44
ARG env_name=python310

docs/using/recipe_code/dask_jupyterlab.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
# Install the Dask dashboard
44
RUN mamba install --yes 'dask-labextension' && \

docs/using/recipe_code/jupyterhub_version.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
RUN mamba install --yes 'jupyterhub==4.0.1' && \
44
mamba clean --all -f -y && \

docs/using/recipe_code/mamba_install.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
RUN mamba install --yes 'flake8' && \
44
mamba clean --all -f -y && \

docs/using/recipe_code/manpage_install.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
44
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014

docs/using/recipe_code/microsoft_odbc.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
44
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014

docs/using/recipe_code/oracledb.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
USER root
44

docs/using/recipe_code/pip_install.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
# Install in the default python3 environment
44
RUN pip install --no-cache-dir 'flake8' && \

docs/using/recipe_code/rise_jupyterlab.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
RUN mamba install --yes 'jupyterlab_rise' && \
44
mamba clean --all -f -y && \

docs/using/recipe_code/spellcheck_notebookv6.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook:notebook-6.5.4
1+
FROM docker.io/jupyter/base-notebook:notebook-6.5.4
22

33
RUN pip install --no-cache-dir 'jupyter_contrib_nbextensions' && \
44
jupyter contrib nbextension install --user && \

docs/using/recipe_code/xgboost.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jupyter/base-notebook
1+
FROM docker.io/jupyter/base-notebook
22

33
RUN mamba install --yes 'py-xgboost' && \
44
mamba clean --all -f -y && \

docs/using/recipes.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ This recipe is not tested and might be broken.
298298
```
299299

300300
```dockerfile
301-
FROM jupyter/all-spark-notebook
301+
FROM docker.io/jupyter/all-spark-notebook
302302

303303
# Set env vars for pydoop
304304
ENV HADOOP_HOME /usr/local/hadoop-2.7.3
@@ -415,7 +415,7 @@ Please note that the [Delta Lake](https://delta.io/) packages are only available
415415
By adding the properties to `spark-defaults.conf`, the user no longer needs to enable Delta support in each notebook.
416416

417417
```dockerfile
418-
FROM jupyter/pyspark-notebook
418+
FROM docker.io/jupyter/pyspark-notebook
419419

420420
RUN mamba install --yes 'delta-spark' && \
421421
mamba clean --all -f -y && \
@@ -446,7 +446,7 @@ This recipe is not tested and might be broken.
446446
The example below is a Dockerfile to load Source Han Sans with normal weight, usually used for the web.
447447

448448
```dockerfile
449-
FROM jupyter/scipy-notebook
449+
FROM docker.io/jupyter/scipy-notebook
450450

451451
RUN PYV=$(ls "${CONDA_DIR}/lib" | grep ^python) && \
452452
MPL_DATA="${CONDA_DIR}/lib/${PYV}/site-packages/matplotlib/mpl-data" && \
@@ -489,7 +489,7 @@ This recipe is not tested and might be broken.
489489
The example below is a Dockerfile to install the [ijavascript kernel](https://github.com/n-riesco/ijavascript).
490490

491491
```dockerfile
492-
FROM jupyter/scipy-notebook
492+
FROM docker.io/jupyter/scipy-notebook
493493

494494
# install ijavascript
495495
RUN npm install -g ijavascript

examples/docker-compose/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ You can customize the docker-stack notebook image to deploy by modifying the `no
4242
For example, you can build and deploy a `jupyter/all-spark-notebook` by modifying the Dockerfile like so:
4343

4444
```dockerfile
45-
FROM jupyter/all-spark-notebook
45+
FROM docker.io/jupyter/all-spark-notebook
4646
# Your RUN commands and so on
4747
```
4848

examples/docker-compose/notebook/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Distributed under the terms of the Modified BSD License.
33

44
# Pick your favorite docker-stacks image
5-
FROM jupyter/minimal-notebook
5+
FROM docker.io/jupyter/minimal-notebook
66

77
USER root
88

examples/make-deploy/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Distributed under the terms of the Modified BSD License.
33

44
# Pick your favorite docker-stacks image
5-
FROM jupyter/minimal-notebook
5+
FROM docker.io/jupyter/minimal-notebook
66

77
USER root
88

images/all-spark-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/pyspark-notebook
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/pyspark-notebook
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

images/base-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/docker-stacks-foundation
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/docker-stacks-foundation
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

images/datascience-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/scipy-notebook
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/scipy-notebook
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

images/julia-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/minimal-notebook
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/minimal-notebook
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

images/minimal-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/base-notebook
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/base-notebook
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

images/pyspark-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/scipy-notebook
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/scipy-notebook
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

images/r-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/minimal-notebook
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/minimal-notebook
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

images/scipy-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/minimal-notebook
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/minimal-notebook
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

images/tensorflow-notebook/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
ARG REGISTRY=docker.io
34
ARG OWNER=jupyter
4-
ARG BASE_CONTAINER=$OWNER/scipy-notebook
5+
ARG BASE_CONTAINER=$REGISTRY/$OWNER/scipy-notebook
56
FROM $BASE_CONTAINER
67

78
LABEL maintainer="Jupyter Project <[email protected]>"

tagging/apply_tags.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
def apply_tags(
1818
short_image_name: str,
19+
registry: str,
1920
owner: str,
2021
tags_dir: Path,
2122
platform: str,
@@ -26,7 +27,7 @@ def apply_tags(
2627
"""
2728
LOGGER.info(f"Tagging image: {short_image_name}")
2829

29-
image = f"{owner}/{short_image_name}:latest"
30+
image = f"{registry}/{owner}/{short_image_name}:latest"
3031
filename = f"{platform}-{short_image_name}.txt"
3132
tags = (tags_dir / filename).read_text().splitlines()
3233

@@ -60,6 +61,13 @@ def apply_tags(
6061
choices=["x86_64", "aarch64", "arm64"],
6162
help="Image platform",
6263
)
64+
arg_parser.add_argument(
65+
"--registry",
66+
required=True,
67+
type=str,
68+
choices=["docker.io", "quay.io"],
69+
help="Image registry",
70+
)
6371
arg_parser.add_argument(
6472
"--owner",
6573
required=True,
@@ -68,4 +76,6 @@ def apply_tags(
6876
args = arg_parser.parse_args()
6977
args.platform = unify_aarch64(args.platform)
7078

71-
apply_tags(args.short_image_name, args.owner, args.tags_dir, args.platform)
79+
apply_tags(
80+
args.short_image_name, args.registry, args.owner, args.tags_dir, args.platform
81+
)

tagging/manifests.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ class ManifestHeader:
2323
"""ManifestHeader doesn't fall under common interface, and we run it separately"""
2424

2525
@staticmethod
26-
def create_header(short_image_name: str, owner: str, build_timestamp: str) -> str:
26+
def create_header(
27+
short_image_name: str, registry: str, owner: str, build_timestamp: str
28+
) -> str:
2729
commit_hash = GitHelper.commit_hash()
2830
commit_hash_tag = GitHelper.commit_hash_tag()
2931
commit_message = GitHelper.commit_message()
3032

3133
image_size = docker[
32-
"images", f"{owner}/{short_image_name}:latest", "--format", "{{.Size}}"
34+
"images",
35+
f"{registry}/{owner}/{short_image_name}:latest",
36+
"--format",
37+
"{{.Size}}",
3338
]().rstrip()
3439

3540
return "\n".join(
@@ -39,7 +44,7 @@ def create_header(short_image_name: str, owner: str, build_timestamp: str) -> st
3944
"## Build Info",
4045
"",
4146
f"* Build datetime: {build_timestamp}",
42-
f"* Docker image: {owner}/{short_image_name}:{commit_hash_tag}",
47+
f"* Docker image: {registry}/{owner}/{short_image_name}:{commit_hash_tag}",
4348
f"* Docker image size: {image_size}",
4449
f"* Git commit SHA: [{commit_hash}](https://github.com/jupyter/docker-stacks/commit/{commit_hash})",
4550
"* Git commit message:",

0 commit comments

Comments
 (0)