From 97ca881a01a04acd35ddeb0b00efde0864f96342 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sun, 4 Jul 2021 18:30:39 +0100 Subject: [PATCH 1/9] Remove automated docker cloud hooks --- Dockerfile | 3 +-- hooks/README.md | 3 --- hooks/post_push | 8 -------- 3 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 hooks/README.md delete mode 100644 hooks/post_push diff --git a/Dockerfile b/Dockerfile index 5cd812ac8..105eb03fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,7 @@ RUN apk add --no-cache git python3 python3-dev py-pip build-base # build wheels in first image ADD . /tmp/src -# restore the hooks directory so that the repository isn't marked as dirty -RUN cd /tmp/src && git clean -xfd && git checkout -- hooks && git status +RUN cd /tmp/src && git clean -xfd && git status RUN mkdir /tmp/wheelhouse \ && cd /tmp/wheelhouse \ && pip3 install wheel \ diff --git a/hooks/README.md b/hooks/README.md deleted file mode 100644 index 0ff34e00f..000000000 --- a/hooks/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Docker build hooks - -These define our [custom hooks for docker automated builds](https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks) diff --git a/hooks/post_push b/hooks/post_push deleted file mode 100644 index d03f1c6b1..000000000 --- a/hooks/post_push +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# when building jupyter/repo2docker:main -# also push jupyter/repo2docker:1.2.3-3.abcd1234 (replace + with -) -version=$(docker run $DOCKER_REPO:$DOCKER_TAG jupyter-repo2docker --version | sed s@+@-@) -VERSION_IMAGE="$DOCKER_REPO:$version" -docker tag $DOCKER_REPO:$DOCKER_TAG "$VERSION_IMAGE" -docker push "$VERSION_IMAGE" From 0468715500fcf79237dbf20eaf305ff34991d7f2 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sun, 4 Jul 2021 19:12:41 +0100 Subject: [PATCH 2/9] Build docker images for amd64 arm64 --- .github/workflows/release.yml | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8a5f30e7..f2c85e8f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,3 +32,66 @@ jobs: uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.PYPI_API_TOKEN }} + + publish-docker: + runs-on: ubuntu-20.04 + + services: + # So that we can test this in PRs/branches + local-registry: + image: registry:2 + ports: + - 5000:5000 + + steps: + - name: Should we push this image to a public registry? + run: | + if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/master') }}" = "true" ]; then + # Empty => Docker Hub + echo "REGISTRY=" >> $GITHUB_ENV + else + echo "REGISTRY=localhost:5000/" >> $GITHUB_ENV + fi + + # versioneer requires the full git history for non-tags + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # Setup docker to build for multiple platforms, see: + # https://github.com/docker/build-push-action/tree/v2.4.0#usage + # https://github.com/docker/build-push-action/blob/v2.4.0/docs/advanced/multi-platform.md + + - name: Set up QEMU (for docker buildx) + uses: docker/setup-qemu-action@25f0500ff22e406f7191a2a8ba8cda16901ca018 + + - name: Set up Docker Buildx (for multi-arch builds) + uses: docker/setup-buildx-action@2a4b53665e15ce7d7049afb11ff1f70ff1610609 + with: + # Allows pushing to registry on localhost:5000 + driver-opts: network=host + + - name: Setup push rights to Docker Hub + if: env.REGISTRY != 'localhost:5000/' + run: | + docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" -p "${{ secrets.DOCKERHUB_TOKEN }}" + + # when building jupyter/repo2docker:master + # also push jupyter/repo2docker:1.2.3-3.abcd1234 (replace + with -) + - name: Get list of repo2docker docker tags + run: | + VERSION=$(python3 -c 'import versioneer; print(versioneer.get_version().replace("+", "-"))') + TAGS="${{ env.REGISTRY }}jupyter/repo2docker:$VERSION" + if [ "${{ github.ref }}" == "refs/heads/master" ]; then + TAGS="$TAGS,${{ env.REGISTRY }}jupyter/repo2docker:master" + fi + echo "TAGS=$TAGS" + echo "TAGS=$TAGS" >> $GITHUB_ENV + + - name: Build and push repo2docker + uses: docker/build-push-action@e1b7f96249f2e4c8e4ac1519b9608c0d48944a1f + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ env.TAGS }} From e6f49668810ddc471f0b2cdaafc72aa62003d2e6 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Wed, 4 Aug 2021 21:15:03 +0100 Subject: [PATCH 3/9] Remove arm64 for now --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f2c85e8f7..8adf6119b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -92,6 +92,6 @@ jobs: uses: docker/build-push-action@e1b7f96249f2e4c8e4ac1519b9608c0d48944a1f with: context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 push: true tags: ${{ env.TAGS }} From c6f09ea2e484dbda6df19419b49bc9e8cb39fe45 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Thu, 12 Aug 2021 23:17:10 +0100 Subject: [PATCH 4/9] Switch to main --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8adf6119b..eeac12153 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,7 +46,7 @@ jobs: steps: - name: Should we push this image to a public registry? run: | - if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/master') }}" = "true" ]; then + if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then # Empty => Docker Hub echo "REGISTRY=" >> $GITHUB_ENV else @@ -82,8 +82,8 @@ jobs: run: | VERSION=$(python3 -c 'import versioneer; print(versioneer.get_version().replace("+", "-"))') TAGS="${{ env.REGISTRY }}jupyter/repo2docker:$VERSION" - if [ "${{ github.ref }}" == "refs/heads/master" ]; then - TAGS="$TAGS,${{ env.REGISTRY }}jupyter/repo2docker:master" + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + TAGS="$TAGS,${{ env.REGISTRY }}jupyter/repo2docker:main" fi echo "TAGS=$TAGS" echo "TAGS=$TAGS" >> $GITHUB_ENV From ca769b373cb55fb65b66965fd681dc36ffbe1c22 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 13 Aug 2021 11:09:31 +0100 Subject: [PATCH 5/9] release.yml workflow name: Publish --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eeac12153..dc437ec8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Create a release on pypi.org +name: Publish on: push: From b45db5acf9e71c1774a89376adf92baee33e65b2 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sat, 21 Aug 2021 17:48:45 +0100 Subject: [PATCH 6/9] Update release workflow for quay.io jupyterhub/repo2docker --- .github/workflows/release.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc437ec8c..cc04737d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,6 +35,11 @@ jobs: publish-docker: runs-on: ubuntu-20.04 + env: + DEFAULT_REGISTRY: quay.io + IMAGE_NAME: jupyterhub/repo2docker + # Secrets are in a separate GitHub environment so only this job and branch has access + environment: quay.io services: # So that we can test this in PRs/branches @@ -47,11 +52,11 @@ jobs: - name: Should we push this image to a public registry? run: | if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then - # Empty => Docker Hub - echo "REGISTRY=" >> $GITHUB_ENV + echo "REGISTRY=$DEFAULT_REGISTRY" >> $GITHUB_ENV else - echo "REGISTRY=localhost:5000/" >> $GITHUB_ENV + echo "REGISTRY=localhost:5000" >> $GITHUB_ENV fi + echo "Publishing to $REGISTRY" # versioneer requires the full git history for non-tags - uses: actions/checkout@v2 @@ -72,18 +77,18 @@ jobs: driver-opts: network=host - name: Setup push rights to Docker Hub - if: env.REGISTRY != 'localhost:5000/' + if: env.REGISTRY != 'localhost:5000' run: | - docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" -p "${{ secrets.DOCKERHUB_TOKEN }}" + docker login -u "${{ secrets.DOCKER_REGISTRY_USERNAME }}" -p "${{ secrets.DOCKER_REGISTRY_TOKEN }}" "${{ env.REGISTRY }}" # when building jupyter/repo2docker:master # also push jupyter/repo2docker:1.2.3-3.abcd1234 (replace + with -) - name: Get list of repo2docker docker tags run: | VERSION=$(python3 -c 'import versioneer; print(versioneer.get_version().replace("+", "-"))') - TAGS="${{ env.REGISTRY }}jupyter/repo2docker:$VERSION" + TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$VERSION" if [ "${{ github.ref }}" == "refs/heads/main" ]; then - TAGS="$TAGS,${{ env.REGISTRY }}jupyter/repo2docker:main" + TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main" fi echo "TAGS=$TAGS" echo "TAGS=$TAGS" >> $GITHUB_ENV From bd58a4a7d484f308cefb1fb5145f756a25b4ba4a Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sat, 21 Aug 2021 17:50:03 +0100 Subject: [PATCH 7/9] Add Docker image quay.io to README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 5cf08cd8d..a6d277355 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Build Status](https://github.com/jupyterhub/repo2docker/workflows/Continuous%20Integration/badge.svg)](https://github.com/jupyterhub/repo2docker/actions) [![Documentation Status](https://readthedocs.org/projects/repo2docker/badge/?version=latest)](http://repo2docker.readthedocs.io/en/latest/?badge=latest) [![Contribute](https://img.shields.io/badge/I_want_to_contribute!-grey?logo=jupyter)](https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html) +[![Docker Repository on Quay](https://quay.io/repository/jupyterhub/repo2docker/status "Docker Repository on Quay")](https://quay.io/repository/jupyterhub/repo2docker) `repo2docker` fetches a git repository and builds a container image based on the configuration files found in the repository. @@ -95,3 +96,8 @@ files that ``repo2docker`` can use, see the The philosophy of repo2docker is inspired by [Heroku Build Packs](https://devcenter.heroku.com/articles/buildpacks). + + +## Docker Image + +Repo2Docker can be run inside a Docker container if access to the Docker Daemon is provided, for example see [BinderHub](https://github.com/jupyterhub/binderhub). Docker images are [published to quay.io](https://quay.io/repository/jupyterhub/repo2docker). The old [Docker Hub image](https://hub.docker.com/r/jupyter/repo2docker) is no longer supported. From b2093423568682d6cd56e8d85bdc8beb2abd2778 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sat, 21 Aug 2021 17:52:05 +0100 Subject: [PATCH 8/9] Remove environment requirement from docker publish workflow This seems to prevent the workflow running in PRs --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc04737d1..8f3476007 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,8 +38,6 @@ jobs: env: DEFAULT_REGISTRY: quay.io IMAGE_NAME: jupyterhub/repo2docker - # Secrets are in a separate GitHub environment so only this job and branch has access - environment: quay.io services: # So that we can test this in PRs/branches From 3ce97e207d1b2d1c87a8659dabaf707df4c8bb4f Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sat, 21 Aug 2021 18:01:33 +0100 Subject: [PATCH 9/9] docker workflow: Ensure $REGISTRY is printed GITHUB_ENV only takes effect on following actions --- .github/workflows/release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f3476007..be0200728 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,10 +50,11 @@ jobs: - name: Should we push this image to a public registry? run: | if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then - echo "REGISTRY=$DEFAULT_REGISTRY" >> $GITHUB_ENV + REGISTRY=$DEFAULT_REGISTRY else - echo "REGISTRY=localhost:5000" >> $GITHUB_ENV + REGISTRY=localhost:5000 fi + echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV echo "Publishing to $REGISTRY" # versioneer requires the full git history for non-tags