Skip to content

Commit b3fb4cc

Browse files
authored
Merge pull request #1071 from manics/github-workflow-docker-push
GitHub workflow build and push to Docker hub
2 parents 297c795 + 3ce97e2 commit b3fb4cc

File tree

5 files changed

+75
-14
lines changed

5 files changed

+75
-14
lines changed

.github/workflows/release.yml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create a release on pypi.org
1+
name: Publish
22

33
on:
44
push:
@@ -32,3 +32,70 @@ jobs:
3232
uses: pypa/gh-action-pypi-publish@master
3333
with:
3434
password: ${{ secrets.PYPI_API_TOKEN }}
35+
36+
publish-docker:
37+
runs-on: ubuntu-20.04
38+
env:
39+
DEFAULT_REGISTRY: quay.io
40+
IMAGE_NAME: jupyterhub/repo2docker
41+
42+
services:
43+
# So that we can test this in PRs/branches
44+
local-registry:
45+
image: registry:2
46+
ports:
47+
- 5000:5000
48+
49+
steps:
50+
- name: Should we push this image to a public registry?
51+
run: |
52+
if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then
53+
REGISTRY=$DEFAULT_REGISTRY
54+
else
55+
REGISTRY=localhost:5000
56+
fi
57+
echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV
58+
echo "Publishing to $REGISTRY"
59+
60+
# versioneer requires the full git history for non-tags
61+
- uses: actions/checkout@v2
62+
with:
63+
fetch-depth: 0
64+
65+
# Setup docker to build for multiple platforms, see:
66+
# https://github.com/docker/build-push-action/tree/v2.4.0#usage
67+
# https://github.com/docker/build-push-action/blob/v2.4.0/docs/advanced/multi-platform.md
68+
69+
- name: Set up QEMU (for docker buildx)
70+
uses: docker/setup-qemu-action@25f0500ff22e406f7191a2a8ba8cda16901ca018
71+
72+
- name: Set up Docker Buildx (for multi-arch builds)
73+
uses: docker/setup-buildx-action@2a4b53665e15ce7d7049afb11ff1f70ff1610609
74+
with:
75+
# Allows pushing to registry on localhost:5000
76+
driver-opts: network=host
77+
78+
- name: Setup push rights to Docker Hub
79+
if: env.REGISTRY != 'localhost:5000'
80+
run: |
81+
docker login -u "${{ secrets.DOCKER_REGISTRY_USERNAME }}" -p "${{ secrets.DOCKER_REGISTRY_TOKEN }}" "${{ env.REGISTRY }}"
82+
83+
# when building jupyter/repo2docker:master
84+
# also push jupyter/repo2docker:1.2.3-3.abcd1234 (replace + with -)
85+
- name: Get list of repo2docker docker tags
86+
run: |
87+
VERSION=$(python3 -c 'import versioneer; print(versioneer.get_version().replace("+", "-"))')
88+
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$VERSION"
89+
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
90+
TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main"
91+
fi
92+
echo "TAGS=$TAGS"
93+
echo "TAGS=$TAGS" >> $GITHUB_ENV
94+
95+
- name: Build and push repo2docker
96+
uses: docker/build-push-action@e1b7f96249f2e4c8e4ac1519b9608c0d48944a1f
97+
with:
98+
context: .
99+
platforms: linux/amd64
100+
push: true
101+
tags: ${{ env.TAGS }}

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ RUN apk add --no-cache git python3 python3-dev py-pip build-base
55

66
# build wheels in first image
77
ADD . /tmp/src
8-
# restore the hooks directory so that the repository isn't marked as dirty
9-
RUN cd /tmp/src && git clean -xfd && git checkout -- hooks && git status
8+
RUN cd /tmp/src && git clean -xfd && git status
109
RUN mkdir /tmp/wheelhouse \
1110
&& cd /tmp/wheelhouse \
1211
&& pip3 install wheel \

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Build Status](https://github.com/jupyterhub/repo2docker/workflows/Continuous%20Integration/badge.svg)](https://github.com/jupyterhub/repo2docker/actions)
44
[![Documentation Status](https://readthedocs.org/projects/repo2docker/badge/?version=latest)](http://repo2docker.readthedocs.io/en/latest/?badge=latest)
55
[![Contribute](https://img.shields.io/badge/I_want_to_contribute!-grey?logo=jupyter)](https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html)
6+
[![Docker Repository on Quay](https://quay.io/repository/jupyterhub/repo2docker/status "Docker Repository on Quay")](https://quay.io/repository/jupyterhub/repo2docker)
67

78
`repo2docker` fetches a git repository and builds a container image based on
89
the configuration files found in the repository.
@@ -95,3 +96,8 @@ files that ``repo2docker`` can use, see the
9596

9697
The philosophy of repo2docker is inspired by
9798
[Heroku Build Packs](https://devcenter.heroku.com/articles/buildpacks).
99+
100+
101+
## Docker Image
102+
103+
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.

hooks/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

hooks/post_push

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)