Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
egagli authored Dec 29, 2023
0 parents commit e5cdcc7
Show file tree
Hide file tree
Showing 11 changed files with 388 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DOCKER_IMAGE=uwhackweek/template
56 changes: 56 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI
on:
push:
branches:
- main
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.gitignore'

jobs:
build-image-and-push:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Set Docker Image Name Environment Variable
run: cat .env >> $GITHUB_ENV

- name: Get CalenderVersion UTC Date
id: calver
run: echo "::set-output name=version::$(date +'%Y.%m.%d')"

- name: Build and Push to DockerHub
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
if: env.DOCKER_PASSWORD != ''
uses: jupyterhub/repo2docker-action@master
with:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_NAME: ${{ env.DOCKER_IMAGE }}
ADDITIONAL_TAG: ${{ steps.calver.outputs.version }}

- name: Also Push To quay.io
env:
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
if: env.QUAY_PASSWORD != ''
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.DOCKER_IMAGE }}
tags: ${{ steps.calver.outputs.version }}
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

- name: Report Image Size and Conda Packages
if: always()
run: |
docker images
docker run ${{ env.DOCKER_IMAGE }}:latest conda list --export
44 changes: 44 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: BuildAndTest
on:
pull_request:
branches:
- main
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.gitignore'

jobs:
build-image-without-pushing:
runs-on: ubuntu-20.04
steps:
- name: Checkout PR
uses: actions/checkout@v2

- name: Set Docker Image Name Environment Variable
run: cat .env >> $GITHUB_ENV

- name: Build Only
uses: jupyterhub/repo2docker-action@master
with:
NO_PUSH: 'true'
IMAGE_NAME: ${{ env.DOCKER_IMAGE }}

- name: Report Image Size and Conda Packages
run: |
docker images
docker run ${{ env.DOCKER_IMAGE }}:latest conda list --export
docker run ${{ env.DOCKER_IMAGE }}:latest conda list --explicit > conda-linux-64.lock
- name: Save package list
uses: actions/upload-artifact@v2
with:
name: lockfile
path: conda-linux-64.lock

- name: Commit lockfile
uses: EndBug/add-and-commit@v7
with:
default_author: github_actions
message: "add conda-lock package list"
add: conda-linux-64.lock
34 changes: 34 additions & 0 deletions .github/workflows/PRbadge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: AddBinderBadge
on:
pull_request_target:
branches:
- main
types: [opened]
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.gitignore'

jobs:
build-image-without-pushing:
runs-on: ubuntu-20.04
steps:
- name: Checkout PR
uses: actions/checkout@v2

- name: Comment on PR with Binder link
uses: actions/github-script@v3
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
CONTENT_REPO: ${{ github.event.pull_request.head.repo.full_name }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var BRANCH_NAME = process.env.BRANCH_NAME;
var CONTENT_REPO = process.env.CONTENT_REPO;
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/${CONTENT_REPO}/${BRANCH_NAME}?urlpath=lab) :point_left: Launch a binder notebook on this branch`
})
35 changes: 35 additions & 0 deletions .github/workflows/Rebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Rebuild
on:
workflow_dispatch:
branches:
- main
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.gitignore'

jobs:
trigger-build:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Get CalenderVersion UTC Date
id: calver
run: echo "::set-output name=version::$(date +'%Y.%m.%d')"

# This file will be overwritten in Pull Request CI Workflow
- name: Update lockfile
run: |
sed -i "1s/.*/#REBUILD/" conda-linux-64.lock
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
title: Rebuild and lock environment (${{ steps.calver.outputs.version }})
commit-message: "Rebuild ${{ steps.calver.outputs.version }}"
body: |
Manually triggered by ./github/workflows/Rebuild.yml
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
130 changes: 130 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 uwhackweek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# docker-template
This repository builds a [JupyterHub](https://jupyter.org/hub) environment with Repo2Docker [GitHub Actions CI](https://github.com/jupyterhub/repo2docker-action)

[![Action Status](https://github.com/uwhackweek/docker-template/workflows/CI/badge.svg)](https://github.com/uwhackweek/docker-template/actions)
[![Docker Pulls](https://img.shields.io/docker/pulls/uwhackweeks/template)](https://hub.docker.com/r/uwhackweeks/template/tags)
[![BinderHub](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/uwhackweek/docker-template/main?urlpath=git-pull?repo=https://github.com/uwhackweek/jupyterbook-template%26amp%3Bbranch=main%26amp%3Burlpath=lab)

### How to use this template repository

1. Click 'Use this Template' to create a copy of the configuration under your organization
2. Edit README.md
2. Edit `.env` and `docker-compose.yml` with your container storage `org/repository`
3. Ensure you have [GitHub Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) for DOCKER_USERNAME and DOCKER_PASSWORD
4. Build with GitHub Actions simply by pushing to GitHub:
* Commits to 'main' branch build image, by git commit sha and 'latest', and push to DockerHub and Quay.io
* Pull Requests trigger image building without pushing to DockerHub

```bash
git clone https://github.com/uwhackweek/docker-template
cd docker-template
git checkout dev
# make sure dev branch is up-to-date with master
git merge master
# modify environment.yml or other files in binder/
git commit -a -m "modified binder/environment to my liking"
git push
# go to github.com and create a pull request to merge dev changes into master
```

### Pull your image to run a local JupyterLab session

```bash
docker compose up
# Do things in JupyterLab w/ files in local directory
docker compose down
```

### Pull image from respository

* From [DockerHub](https://hub.docker.com/r/uwhackweeks/template/tags): `docker pull uwhackweek/template:latest`
* From [Quay](https://quay.io/repository/uwhackweek/template?tab=tags): `docker pull quay.io/uwhackweek/template:latest`

### Point to a specific tagged image in JupyterHub config

https://zero-to-jupyterhub.readthedocs.io/en/latest/reference/reference.html?highlight=profile_list#singleuser-profilelist
3 changes: 3 additions & 0 deletions apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vim
wget
git
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.9"

services:
jupyterlab:
image: "uwhackweek/template:latest"
ports:
- "8888:8888"
command: "jupyter lab --ip 0.0.0.0 --no-browser"
volumes:
- ${PWD}:/home/jovyan
9 changes: 9 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: hackweek
channels:
- conda-forge
dependencies:
- ipyleaflet
- jupyter-book=0.10
- jupyterlab=3
- jupyter-resource-usage
- sphinxcontrib-bibtex=2

0 comments on commit e5cdcc7

Please sign in to comment.