From 32126b33f082a1044dd7b5840a3151a9f2ae0dfa Mon Sep 17 00:00:00 2001 From: James Munroe Date: Fri, 1 Nov 2024 15:18:24 -0400 Subject: [PATCH 1/2] add a Docker to build image as needed and a license --- Dockerfile | 10 ++++++++++ LICENSE | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 Dockerfile create mode 100644 LICENSE diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fd31805 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +# Inherit from an upstream image +FROM quay.io/jupyter/r-notebook:2024-10-03 + +# Add additional packages +RUN mamba install --yes \ + 'nbgitpuller' \ + 'r-extrafont' && \ + mamba clean --all -f -y && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4ac657e --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2021, 2i2c-org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 53a5ba4285706f0a8bb39bcb8faf25698fcb1c75 Mon Sep 17 00:00:00 2001 From: James Munroe Date: Fri, 1 Nov 2024 15:23:32 -0400 Subject: [PATCH 2/2] add github actions to automatically build image --- .github/workflows/binder.yaml | 30 ++++++++++++++++++++++++++ .github/workflows/build.yaml | 39 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 40 +++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 .github/workflows/binder.yaml create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/binder.yaml b/.github/workflows/binder.yaml new file mode 100644 index 0000000..d5571b3 --- /dev/null +++ b/.github/workflows/binder.yaml @@ -0,0 +1,30 @@ +# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html +name: Test this PR on Binder Badge +on: + pull_request_target: + types: [opened] + +permissions: + pull-requests: + write + +jobs: + binder: + runs-on: ubuntu-latest + steps: + - name: comment on PR with Binder link + uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO; + var PR_HEAD_REF = process.env.PR_HEAD_REF; + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}) :point_left: Test this PR on Binder` + }) + env: + PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} + PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }} diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..73d5274 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,39 @@ +name: Build and push container image + +on: + push: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + + # For biggish images, github actions runs out of disk space. + # So we cleanup some unwanted things in the disk image, and reclaim that space for our docker use + # https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150 + # and https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L104 + # This gives us a total of about 52G of free space, which should be enough for now + - name: cleanup disk space + run: | + sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc + df -h + + - name: Checkout files in repo + uses: actions/checkout@main + + - name: Build and push the image to quay.io + uses: jupyterhub/repo2docker-action@master + with: + # Make sure username & password/token pair matches your registry credentials + DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + DOCKER_REGISTRY: "quay.io" + # + # Uncomment and modify the following line with your image name, otherwise no push will happen + IMAGE_NAME: "highereddata/du-bois-stem" + + # Lets us monitor disks getting full as images get bigger over time + - name: Show how much disk space is left + run: df -h diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..390ffb3 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,40 @@ +name: Test container image build + +on: + pull_request: + +jobs: + test-build: + runs-on: ubuntu-latest + steps: + + # For biggish images, github actions runs out of disk space. + # So we cleanup some unwanted things in the disk image, and reclaim that space for our docker use + # https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150 + # and https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L104 + # This gives us a total of about 52G of free space, which should be enough for now + - name: cleanup disk space + run: | + sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc + df -h + + - name: checkout files in repo + uses: actions/checkout@main + + - name: Build the image and push it if `NO_PUSH` disabled + uses: jupyterhub/repo2docker-action@master + with: + NO_PUSH: "true" + DOCKER_REGISTRY: "quay.io" + # Put repo contents in /srv/repo, rather than the default (/home/jovyan). The home directory + # is mounted over by persistent storage when we are using the built image in a JupyterHub, and + # so all contents put in /home/jovyan are lost. This particularly prevents any 'start' script from + # working, as it is needed in runtime. + REPO_DIR: /srv/repo + + # Uncomment and modify the following line with your image name. + IMAGE_NAME: "cirt_ucm/jupyter-scipy-xarray" + + # Lets us monitor disks getting full as images get bigger over time + - name: Show how much disk space is left + run: df -h