Skip to content

Commit

Permalink
Merge pull request #1071 from manics/github-workflow-docker-push
Browse files Browse the repository at this point in the history
GitHub workflow build and push to Docker hub
  • Loading branch information
manics authored Aug 21, 2021
2 parents 297c795 + 3ce97e2 commit b3fb4cc
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 14 deletions.
69 changes: 68 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create a release on pypi.org
name: Publish

on:
push:
Expand Down Expand Up @@ -32,3 +32,70 @@ jobs:
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}

publish-docker:
runs-on: ubuntu-20.04
env:
DEFAULT_REGISTRY: quay.io
IMAGE_NAME: jupyterhub/repo2docker

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/main') }}" = "true" ]; then
REGISTRY=$DEFAULT_REGISTRY
else
REGISTRY=localhost:5000
fi
echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV
echo "Publishing to $REGISTRY"
# 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.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 }}/${{ env.IMAGE_NAME }}:$VERSION"
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main"
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
push: true
tags: ${{ env.TAGS }}
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
3 changes: 0 additions & 3 deletions hooks/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions hooks/post_push

This file was deleted.

0 comments on commit b3fb4cc

Please sign in to comment.