Skip to content

Commit

Permalink
Setup automated docker image build + push
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Feb 3, 2024
1 parent 47ae5a1 commit fbcc753
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: build

on:
push:
branches: main
pull_request:

jobs:
login:
runs-on: ubuntu-latest
steps:
- name: Figure out docker image tag
id: taggen
uses: docker/metadata-action@v3
with:
images: |
quay.io/yuvipanda/z2jh-hub-with-fancy-profiles
tags: |
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Quay.io
uses: docker/login-action@v1
# Run this only on merge
if: "${{ github.event_name == 'push' }}"
with:
registry: quay.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: "${{ github.event_name == 'push' }}"
tags: ${{ steps.taggen.outputs.tags }}

- name: Image Tag
run: echo ${{ steps.taggen.outputs.tags }}
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG Z2JH_VERSION=3.2.1

# We need node to build the package, but not to run it
# Use the same base image but with nodejs installed as the builder,
# then copy over just the built wheel files for the final image.
# This keeps image size low while also making the whole process
# reasonably simple
FROM quay.io/jupyterhub/k8s-hub:${Z2JH_VERSION} as builder

USER root

RUN apt update > /dev/null && \
apt install --yes nodejs npm >/dev/null

ADD . /srv/repo
RUN pip install build
RUN python -m build /srv/repo --outdir /srv/wheels/

FROM quay.io/jupyterhub/k8s-hub:${Z2JH_VERSION}

USER root
COPY --from=builder /srv/wheels/*.whl /srv/wheels/
RUN pip install /srv/wheels/*

USER ${NB_USER}

0 comments on commit fbcc753

Please sign in to comment.