Merge branch 'master' into asalikhov/automatic_conda_versioning

This commit is contained in:
Ayaz Salikhov
2021-07-17 22:26:46 +03:00
10 changed files with 288 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
name: Build Docker Images
name: Build, test, and publish Docker Images
on:
repository_dispatch:
@@ -24,51 +24,75 @@ on:
- ".pre-commit-config.yaml"
jobs:
build-images:
name: Build Docker Images
build-test-publish-images:
name: Build, test, and publish Docker Images
runs-on: ubuntu-latest
permissions:
contents: write
if: >
!contains(github.event.head_commit.message, 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip')
steps:
# Setup docker to build for multiple platforms, see:
# https://github.com/docker/build-push-action/tree/master#usage
# https://github.com/docker/build-push-action/blob/master/docs/advanced/multi-platform.md
- name: Set up QEMU (for docker buildx)
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # dependabot updates to latest release
- name: Set up Docker Buildx (for multi-arch builds)
uses: docker/setup-buildx-action@0d135e0c2fc0dba0729c1a47ecfcf5a3c7f8579e # dependabot updates to latest release
with:
version: latest
- name: Clone Main Repo
uses: actions/checkout@v2
with:
path: main
- name: Set Up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install Dev Dependencies
run: |
python -m pip install --upgrade pip
make -C main dev-env
- name: Build Docker Images
run: make -C main build-test-all
run: make -C main build-all-multi
env:
# Full logs for CI build
BUILDKIT_PROGRESS: plain
- name: Test Docker Images
run: make -C main test-all
- name: Clone Wiki
uses: actions/checkout@v2
with:
repository: ${{github.repository}}.wiki
path: wiki
- name: Run Post-Build Hooks
id: hook-all
run: make -C main hook-all
- name: Push Wiki to GitHub
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
uses: stefanzweifel/git-auto-commit-action@5dd17c3b53a58c1cb5eaab903826abe94765ccd6 # dependabot updates to latest release
with:
commit_message: "[ci skip] Automated publish for ${{github.sha}}"
repository: wiki/
- name: Login to Docker Hub
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 # dependabot updates to latest release
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Push Images to DockerHub
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
run: make -C main push-all
run: make -C main push-all-multi

View File

@@ -14,18 +14,22 @@ jobs:
if: >
!contains(github.event.head_commit.message, 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip')
steps:
- name: Clone Main Repo
uses: actions/checkout@v2
with:
path: main
- name: Set Up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
- name: Run pre-commit hooks
run: make -C main pre-commit-all

View File

@@ -22,24 +22,30 @@ jobs:
if: >
!contains(github.event.head_commit.message , 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip')
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Set Up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install Dev Dependencies
run: |
python -m pip install --upgrade pip
make dev-env
- name: Build Documentation
run: make docs
- name: Extract Source Strings
working-directory: docs
run: |
sphinx-build -M gettext ./ ./_build/
sphinx-intl update -p ./_build/gettext -l en
- name: Push Strings to Master
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
uses: stefanzweifel/git-auto-commit-action@5dd17c3b53a58c1cb5eaab903826abe94765ccd6 # dependabot updates to latest release

133
Makefile
View File

@@ -7,7 +7,24 @@ SHELL:=bash
OWNER?=jupyter
# Need to list the images in build dependency order
ALL_IMAGES:=base-notebook \
# Images supporting the following architectures:
# - linux/amd64
# - linux/arm64
MULTI_IMAGES:= \
base-notebook \
minimal-notebook
# Images that can only be built on the amd64 architecture (aka. x86_64)
AMD64_ONLY_IMAGES:= \
r-notebook \
scipy-notebook \
tensorflow-notebook \
datascience-notebook \
pyspark-notebook \
all-spark-notebook
# All of the images
ALL_IMAGES:= \
base-notebook \
minimal-notebook \
r-notebook \
scipy-notebook \
@@ -19,37 +36,98 @@ ALL_IMAGES:=base-notebook \
# Enable BuildKit for Docker build
export DOCKER_BUILDKIT:=1
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@echo "jupyter/docker-stacks"
@echo "====================="
@echo "Replace % with a stack directory name (e.g., make build/minimal-notebook)"
@echo "Replace % with a stack directory name (e.g., make build-multi/minimal-notebook)"
@echo
@grep -E '^[a-zA-Z0-9_%/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build/%: DARGS?=
build/%: ## build the latest image for a stack
docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest --build-arg OWNER=$(OWNER) ./$(notdir $@)
build/%: ## build the latest image for a stack using the system's architecture
@echo "::group::Build $(OWNER)/$(notdir $@) (system's architecture)"
docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER)
@echo -n "Built image size: "
@docker images $(OWNER)/$(notdir $@):latest --format "{{.Size}}"
@echo "::endgroup::"
build-all: $(foreach I, $(ALL_IMAGES), build/$(I)) ## build all stacks
# Limitations on docker buildx build (using docker/buildx 0.5.1):
#
# 1. Can't --load and --push at the same time
#
# 2. Can't --load multiple platforms
#
# What does it mean to --load?
#
# - It means that the built image can be referenced by `docker` CLI, for example
# when using the `docker tag` or `docker push` commands.
#
# Workarounds due to limitations:
#
# 1. We always build a dedicated image using the current system architecture
# named as OWNER/<stack>-notebook so we always can reference that image no
# matter what during tests etc.
#
# 2. We always also build a multi-platform image during build-multi that will be
# inaccessible with `docker tag` and `docker push` etc, but this will help us
# test the build on the different platform and provide cached layers for
# later.
#
# 3. We let push-multi refer to rebuilding a multi image with `--push`.
#
# We can rely on the cached layer from build-multi now even though we never
# tagged the multi image.
#
# Outcomes of the workaround:
#
# 1. We can keep using the previously defined Makefile commands that doesn't
# include `-multi` suffix as before.
#
# 2. Assuming we have setup docker/dockerx properly to build in arm64
# architectures as well, then we can build and publish such images via the
# `-multi` suffix without needing a local registry.
#
# 3. If we get dedicated arm64 runners, we can test everything separately
# without needing to update this Makefile, and if all tests succeeds we can
# do a publish job that creates a multi-platform image for us.
#
build-multi/%: DARGS?=
build-multi/%: ## build the latest image for a stack on both amd64 and arm64
@echo "::group::Build $(OWNER)/$(notdir $@) (system's architecture)"
docker buildx build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER)
@echo -n "Built image size: "
@docker images $(OWNER)/$(notdir $@):latest --format "{{.Size}}"
@echo "::endgroup::"
@echo "::group::Build $(OWNER)/$(notdir $@) (amd64,arm64)"
docker buildx build $(DARGS) --rm --force-rm -t build-multi-tmp-cache/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER) --platform "linux/amd64,linux/arm64"
@echo "::endgroup::"
build-all-multi: $(foreach I, $(MULTI_IMAGES), build-multi/$(I)) $(foreach I, $(AMD64_ONLY_IMAGES), build/$(I)) ## build all stacks
build-all: $(foreach I,$(ALL_IMAGES), build/$(I) ) ## build all stacks
build-test-all: $(foreach I,$(ALL_IMAGES), build/$(I) test/$(I) ) ## build and test all stacks
check-outdated/%: ## check the outdated conda packages in a stack and produce a report (experimental)
@TEST_IMAGE="$(OWNER)/$(notdir $@)" pytest test/test_outdated.py
check-outdated-all: $(foreach I,$(ALL_IMAGES), check-outdated/$(I) ) ## check all the stacks for outdated conda packages
check-outdated-all: $(foreach I, $(ALL_IMAGES), check-outdated/$(I)) ## check all the stacks for outdated conda packages
cont-clean-all: cont-stop-all cont-rm-all ## clean all containers (stop + rm)
cont-stop-all: ## stop all containers
@echo "Stopping all containers ..."
-docker stop -t0 $(shell docker ps -a -q) 2> /dev/null
cont-rm-all: ## remove all containers
@echo "Removing all containers ..."
-docker rm --force $(shell docker ps -a -q) 2> /dev/null
dev/%: ARGS?=
dev/%: DARGS?=-e JUPYTER_ENABLE_LAB=yes
dev/%: PORT?=8888
@@ -59,48 +137,62 @@ dev/%: ## run a foreground container for a stack
dev-env: ## install libraries required to build docs and run tests
@pip install -r requirements-dev.txt
docs: ## build HTML documentation
sphinx-build docs/ docs/_build/
hook/%: WIKI_PATH?=../wiki
hook/%: ## run post-build hooks for an image
python3 -m tagging.tag_image --short-image-name "$(notdir $@)" --owner "$(OWNER)" && \
python3 -m tagging.create_manifests --short-image-name "$(notdir $@)" --owner "$(OWNER)" --wiki-path "$(WIKI_PATH)"
hook-all: $(foreach I, $(ALL_IMAGES), hook/$(I)) ## run post-build hooks for all images
hook-all: $(foreach I,$(ALL_IMAGES),hook/$(I) ) ## run post-build hooks for all images
img-clean: img-rm-dang img-rm ## clean dangling and jupyter images
img-list: ## list jupyter images
@echo "Listing $(OWNER) images ..."
docker images "$(OWNER)/*"
img-rm: ## remove jupyter images
@echo "Removing $(OWNER) images ..."
-docker rmi --force $(shell docker images --quiet "$(OWNER)/*") 2> /dev/null
img-rm-dang: ## remove dangling images (tagged None)
@echo "Removing dangling images ..."
-docker rmi --force $(shell docker images -f "dangling=true" -q) 2> /dev/null
pre-commit-all: ## run pre-commit hook on all files
@pre-commit run --all-files || (printf "\n\n\n" && git --no-pager diff --color=always)
pre-commit-install: ## set up the git hook scripts
@pre-commit --version
@pre-commit install
pull/%: DARGS?=
pull/%: ## pull a jupyter image
docker pull $(DARGS) $(OWNER)/$(notdir $@)
pull-all: $(foreach I,$(ALL_IMAGES),pull/$(I) ) ## pull all images
pull-all: $(foreach I, $(ALL_IMAGES), pull/$(I)) ## pull all images
push/%: DARGS?=
push/%: ## push all tags for a jupyter image
@echo "::group::Push $(OWNER)/$(notdir $@) (system's architecture)"
docker push --all-tags $(DARGS) $(OWNER)/$(notdir $@)
@echo "::endgroup::"
push-all: $(foreach I, $(ALL_IMAGES), push/$(I)) ## push all tagged images
push-multi/%: DARGS?=
push-multi/%: ## push all tags for a jupyter image that support multiple architectures
@echo "::group::Push $(OWNER)/$(notdir $@) (amd64,arm64)"
docker buildx build $(DARGS) --rm --force-rm $($(subst -,_,$(notdir $@))_EXTRA_TAG_ARGS) -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) --build-arg OWNER=$(OWNER) --platform "linux/amd64,linux/arm64" --push
@echo "::endgroup::"
push-all-multi: $(foreach I, $(MULTI_IMAGES), push-multi/$(I)) $(foreach I, $(AMD64_ONLY_IMAGES), push/$(I)) ## push all tagged images
push-all: $(foreach I,$(ALL_IMAGES),push/$(I) ) ## push all tagged images
run/%: DARGS?=
run/%: ## run a bash in interactive mode in a stack
@@ -110,8 +202,11 @@ run-sudo/%: DARGS?=
run-sudo/%: ## run a bash in interactive mode as root in a stack
docker run -it --rm -u root $(DARGS) $(OWNER)/$(notdir $@) $(SHELL)
test/%: ## run tests against a stack (only common tests or common tests + specific tests)
@echo "::group::test/$(OWNER)/$(notdir $@)"
@if [ ! -d "$(notdir $@)/test" ]; then TEST_IMAGE="$(OWNER)/$(notdir $@)" pytest -m "not info" test; \
else TEST_IMAGE="$(OWNER)/$(notdir $@)" pytest -m "not info" test $(notdir $@)/test; fi
test-all: $(foreach I,$(ALL_IMAGES),test/$(I)) ## test all stacks
@echo "::endgroup::"
test-all: $(foreach I, $(ALL_IMAGES), test/$(I)) ## test all stacks

View File

@@ -105,6 +105,18 @@ This change is tracked in the issue [#1217](https://github.com/jupyter/docker-st
- [Jupyter Website](https://jupyter.org)
- [Images on DockerHub](https://hub.docker.com/u/jupyter)
## Architectures
## CPU Architectures
Currently published containers only support x86, some containers may support cross-building with docker buildx.
All published containers support amd64 (x86_64). The base-notebook and
minimal-notebook containers also support arm64. The ambition is to have all
containers support both amd64 and arm64.
### Caveats for arm64 images
- The manifests we publish in this projects wiki as well as the image tags for
the multi platform images that also support arm, are all based on the amd64
version even though details about the installed packages versions could differ
between architectures. For the status about this, see
[#1401](https://github.com/jupyter/docker-stacks/issues/1401).
- Only the amd64 images are actively tested currently. For the status about
this, see [#1402](https://github.com/jupyter/docker-stacks/issues/1402).

View File

@@ -44,10 +44,23 @@ Docker destroys the container after notebook server exit, but any files written
docker run --rm -p 10000:8888 -e JUPYTER_ENABLE_LAB=yes -v "${PWD}":/home/jovyan/work jupyter/datascience-notebook:33add21fab64
Architectures
-----------
Currently published containers only support x86, some containers may support cross-building with docker buildx.
CPU Architectures
-----------------
All published containers support amd64 (x86_64). The base-notebook and
minimal-notebook containers also support arm64. The ambition is to have all
containers support both amd64 and arm64.
Caveats for arm64 images
^^^^^^^^^^^^^^^^^^^^^^^^
- The manifests we publish in this projects wiki as well as the image tags for
the multi platform images that also support arm, are all based on the amd64
version even though details about the installed packages versions could differ
between architectures. For the status about this, see
`#1401 <https://github.com/jupyter/docker-stacks/issues/1401>`_.
- Only the amd64 images are actively tested currently. For the status about
this, see `#1402 <https://github.com/jupyter/docker-stacks/issues/1402>`_.
Table of Contents
-----------------

View File

@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: docker-stacks latest\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-07-08 14:06+0000\n"
"POT-Creation-Date: 2021-07-17 19:24+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -19,44 +19,44 @@ msgstr ""
"Generated-By: Babel 2.9.1\n"
# 22f1bd46933144e092bf92e3af4c6f4f
#: ../../index.rst:55 259addd8d90e4cbeab357be9823cac05
#: ../../index.rst:68 0107cbeadad942a3a8f1ad13905717f9
msgid "User Guide"
msgstr ""
# f35d75046f8c42ae8cab58d826154823
#: ../../index.rst:65 2479218777044cfdb444b6a7e9cd5971
#: ../../index.rst:78 93611fed98a44622bb49af42f5f10d89
msgid "Contributor Guide"
msgstr ""
# a737afe726cd49c4986d75b7d74eeed3
#: ../../index.rst:78 d089d107caef463c8e689748e60a47a7
#: ../../index.rst:91 10679a6d789047e4a984149e4d5d8460
msgid "Maintainer Guide"
msgstr ""
#: ../../index.rst:84
#: ../../index.rst:97
msgid "Issue Tracker on Github"
msgstr ""
#: ../../index.rst:84
#: ../../index.rst:97
msgid "Jupyter Discourse Forum"
msgstr ""
#: ../../index.rst:84
#: ../../index.rst:97
msgid "Jupyter Website"
msgstr ""
# 9cd216fa91ef40bbb957373faaf93732
#: ../../index.rst:84 7674c75edb8e4f02a4834ba9fe620933
#: ../../index.rst:97 2ff354c1c96b47a1a1202cc855064bf8
msgid "Getting Help"
msgstr ""
# a0aa0bcd999c4c5e96cc57fd77780f96
#: ../../index.rst:2 a9c5366b811a4951b1a6d5edca0fea5c
#: ../../index.rst:2 5768d92118e04d098ff180a027f25be2
msgid "Jupyter Docker Stacks"
msgstr ""
# 5d06f458dc524214b2c97e865dd2dc81
#: ../../index.rst:4 af64033317154bb69b9a295fe357741a
#: ../../index.rst:4 f4d126bd06ec44bb8479277998f35533
msgid ""
"Jupyter Docker Stacks are a set of ready-to-run Docker images containing "
"Jupyter applications and interactive computing tools. You can use a stack"
@@ -64,26 +64,26 @@ msgid ""
msgstr ""
# c69f151c806e4cdf9bebda05b06c760e
#: ../../index.rst:7 b02d3a54f9434efabb9ec7cf44573954
#: ../../index.rst:7 d0be0d136eb042c187897d543fad11c8
msgid "Start a personal Jupyter Notebook server in a local Docker container"
msgstr ""
# b26271409ab743b2a349b3a8ca95233e
#: ../../index.rst:8 657f4e715fe5481fb2c06edd5c6fa6b5
#: ../../index.rst:8 1dcca624081540069331b21135cd5734
msgid "Run JupyterLab servers for a team using JupyterHub"
msgstr ""
# 4d60f4325fff4ffcad12703a4b9d6781
#: ../../index.rst:9 faa40cd6f5694bbbaa1c71c8159b8811
#: ../../index.rst:9 c0efa8478a084b63bdb0df042da80e5d
msgid "Write your own project Dockerfile"
msgstr ""
# 78b0d31eb6e9462888eef92e6a84cdb7
#: ../../index.rst:12 f0b4531077c34bf6bb2dc8b62b368cc9
#: ../../index.rst:12 5ef91401308f4c5d8839d612da23c51a
msgid "Quick Start"
msgstr ""
#: ../../index.rst:14 feff58d1445d4f96ab11966c9249526c
#: ../../index.rst:14 89177bf94a9f45619603a83bd4c102ae
msgid ""
"You can try a `relatively recent build of the jupyter/base-notebook image"
" on mybinder.org <https://mybinder.org/v2/gh/jupyter/docker-"
@@ -95,13 +95,13 @@ msgid ""
msgstr ""
# 051ed23ef62e41058a7c889604f96035
#: ../../index.rst:20 cb7785be2f644bd5bc924904777f7e7a
#: ../../index.rst:20 20acd9e5a56a4bd4af5e9f6e2a70c3aa
msgid ""
"The other pages in this documentation describe additional uses and "
"features in detail."
msgstr ""
#: ../../index.rst:22 2bef3917f97b4ea8bb59e87a49445850
#: ../../index.rst:22 beeac1d80f754e18b577beeb4c335185
msgid ""
"**Example 1:** This command pulls the ``jupyter/scipy-notebook`` image "
"tagged ``33add21fab64`` from Docker Hub if it is not already present on "
@@ -114,7 +114,7 @@ msgid ""
"the notebook server exits.::"
msgstr ""
#: ../../index.rst:31 2a72957ec0ef4905903a78e9273cd308
#: ../../index.rst:31 7aa26bcdf1234bffa86dea204b01e5bf
msgid ""
"**Example 2:** This command performs the same operations as **Example "
"1**, but it exposes the server on host port 10000 instead of port 8888. "
@@ -124,7 +124,7 @@ msgid ""
"console.::"
msgstr ""
#: ../../index.rst:37 0b05aa95a5e94138aa8312d3c12dc95b
#: ../../index.rst:37 eca976f6135e45a2a36faefc62539cae
msgid ""
"**Example 3:** This command pulls the ``jupyter/datascience-notebook`` "
"image tagged ``33add21fab64`` from Docker Hub if it is not already "
@@ -139,18 +139,39 @@ msgid ""
"written to ``~/work`` in the container remain intact on the host.::"
msgstr ""
#: ../../index.rst:48 fafd366c8b474a2ca38075195adbdac1
msgid "Architectures"
#: ../../index.rst:48 52c7b7ffd5664518bcb62fdf82701311
msgid "CPU Architectures"
msgstr ""
#: ../../index.rst:49 b5ca90b4a1ff411b9f53843605376677
#: ../../index.rst:50 10973c9bd2e740ea97bd5f601304910f
msgid ""
"Currently published containers only support x86, some containers may "
"support cross-building with docker buildx."
"All published containers support amd64 (x86_64). The base-notebook and "
"minimal-notebook containers also support arm64. The ambition is to have "
"all containers support both amd64 and arm64."
msgstr ""
#: ../../index.rst:55 29bb17b8877c4f5e9a7efc20255fd545
msgid "Caveats for arm64 images"
msgstr ""
#: ../../index.rst:57 15ab54ab30bf4d6bad8a3dc1804a8cd3
msgid ""
"The manifests we publish in this projects wiki as well as the image tags "
"for the multi platform images that also support arm, are all based on the"
" amd64 version even though details about the installed packages versions "
"could differ between architectures. For the status about this, see `#1401"
" <https://github.com/jupyter/docker-stacks/issues/1401>`_."
msgstr ""
#: ../../index.rst:62 de716d354ad744b28f28dc5be060c042
msgid ""
"Only the amd64 images are actively tested currently. For the status about"
" this, see `#1402 <https://github.com/jupyter/docker-"
"stacks/issues/1402>`_."
msgstr ""
# 3ac1a41d185844b1b43315a4cc74efc8
#: ../../index.rst:53 304d5b606a5c4df7be7709e50d7ea069
#: ../../index.rst:66 ee965d10b2ce443c831121664672323f
msgid "Table of Contents"
msgstr ""
@@ -275,3 +296,32 @@ msgstr ""
#~ " in a container."
#~ msgstr ""
#~ msgid "Architectures"
#~ msgstr ""
#~ msgid ""
#~ "Currently published containers only support"
#~ " x86, some containers may support "
#~ "cross-building with docker buildx."
#~ msgstr ""
#~ msgid ""
#~ "The manifests we publish in this "
#~ "projects wiki as well as the image"
#~ " tags for the multi platform images"
#~ " that also support arm, are all "
#~ "based on the amd64 version even "
#~ "though details about the installed "
#~ "packages versions could differ between "
#~ "architectures. For the status about "
#~ "this, see [#1401](https://github.com/jupyter/docker-"
#~ "stacks/issues/1401)."
#~ msgstr ""
#~ msgid ""
#~ "Only the amd64 images are actively "
#~ "tested currently. For the status about"
#~ " this, see [#1402](https://github.com/jupyter"
#~ "/docker-stacks/issues/1402)."
#~ msgstr ""

11
tagging/github_set_env.py Normal file
View File

@@ -0,0 +1,11 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
def github_set_env(env_name, env_value):
if not os.environ.get("GITHUB_ACTIONS") or not os.environ.get("GITHUB_ENV"):
return
with open(os.environ["GITHUB_ENV"], "a") as f:
f.write(f"{env_name}={env_value}\n")

View File

@@ -6,26 +6,43 @@ import logging
from plumbum.cmd import docker
from .docker_runner import DockerRunner
from .get_taggers_and_manifests import get_taggers_and_manifests
from .github_set_env import github_set_env
logger = logging.getLogger(__name__)
def tag_image(short_image_name: str, owner: str) -> None:
"""
Tags <owner>/<short_image_name>:latest with the tags reported by all taggers
for the given image.
Tags are in a GitHub Actions environment also saved to environment variables
in a format making it easy to append them.
"""
logger.info(f"Tagging image: {short_image_name}")
taggers, _ = get_taggers_and_manifests(short_image_name)
image = f"{owner}/{short_image_name}:latest"
with DockerRunner(image) as container:
tags = []
for tagger in taggers:
tagger_name = tagger.__name__
tag_value = tagger.tag_value(container)
tags.append(tag_value)
logger.info(
f"Applying tag tagger_name: {tagger_name} tag_value: {tag_value}"
)
docker["tag", image, f"{owner}/{short_image_name}:{tag_value}"]()
if tags:
env_name = f'{short_image_name.replace("-", "_")}_EXTRA_TAG_ARGS'
docker_build_tag_args = " ".join(
[f"-t {owner}/{short_image_name}:{tag}" for tag in tags]
)
github_set_env(env_name, docker_build_tag_args)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)

View File

@@ -69,6 +69,8 @@ EXCLUDED_PACKAGES = [
"r-irkernel",
"unixodbc",
"bzip2",
"openssl",
"ca-certificates",
]