Skip to content

Commit

Permalink
Merge pull request #12 from yuvipanda/dockerfile
Browse files Browse the repository at this point in the history
Setup automated docker image build + push
yuvipanda authored Feb 3, 2024
2 parents a52431e + 9dad133 commit 57147ff
Showing 2 changed files with 73 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: build docker image

on:
push:
branches: main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# We use setuptools-scm to do versioning, and it needs a full clone
fetch-depth: "0"

- 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.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
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 57147ff

Please sign in to comment.