Skip to content

Commit c2e51b6

Browse files
committed
Add Docker image build (with repo2docker) and Continuous Delivery
1 parent c08ac14 commit c2e51b6

File tree

7 files changed

+181
-0
lines changed

7 files changed

+181
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "Build and push container image"
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths:
8+
- "docker/*"
9+
- ".github/workflows/build-and-publish-docker-image.yml"
10+
11+
12+
permissions:
13+
contents: "read"
14+
packages: "write"
15+
attestations: "write"
16+
id-token: "write"
17+
18+
19+
concurrency:
20+
group: "${{ github.workflow }}-${{ github.ref }}"
21+
cancel-in-progress: false
22+
23+
24+
jobs:
25+
build-and-push:
26+
runs-on: "ubuntu-latest"
27+
steps:
28+
29+
# For biggish images, github actions runs out of disk space.
30+
# So we cleanup some unwanted things in the disk image, and reclaim that space for our docker use
31+
# https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150
32+
# and https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L104
33+
# This gives us a total of about 52G of free space, which should be enough for now
34+
- name: "Cleanup disk space"
35+
run: |
36+
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
37+
df -h
38+
39+
- name: "Checkout files in repo"
40+
uses: "actions/checkout@v5"
41+
42+
- name: "Build and push the image"`
43+
uses: "jupyterhub/repo2docker-action@master"
44+
with:
45+
REPO2DOCKER_EXTRA_ARGS: "--subdir docker"
46+
DOCKER_USERNAME: "${{ github.repository_owner }}"
47+
DOCKER_PASSWORD: "${{ secrets.GITHUB_TOKEN }}"
48+
DOCKER_REGISTRY: "ghcr.io"
49+
# Disable pushing a 'latest' tag, as this often just causes confusion
50+
# LATEST_TAG_OFF: true
51+
IMAGE_NAME: "geojupyter/workshop-open-source-geospatial"
52+
# Put repo contents in /srv/repo, so they aren't mangled when we put user home in /home/jovyan
53+
REPO_DIR: "/srv/repo"
54+
# Fix man pages that are disabled by Ubuntu 18 minimal base image
55+
# APPENDIX_FILE: "appendix"
56+
57+
# Lets us monitor disks getting full as images get bigger over time
58+
- name: "Show how much disk space is left"
59+
run: "df -h"

docker/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# GeoJupyter Docker image
2+
3+
A Docker image containing geospatial tools and libraries needed for this workshop,
4+
intended to be run on [CryoCloud](https://cryointhecloud.com/)
5+
6+
Use this image string in your JupyterHub:
7+
8+
```
9+
ghcr.io/geojupyter/workshop-open-source-geospatial:latest
10+
```
11+
12+
13+
## How it's built
14+
15+
This Docker image is built with
16+
[repo2docker](https://github.com/jupyterhub/repo2docker).
17+
18+
repo2docker enables building and publishing a Docker image without Docker-specific
19+
knowledge.
20+
It uses familiar
21+
[configuration files](https://repo2docker.readthedocs.io/en/latest/config_files.html)
22+
like conda's `environment.yml` to generate the image, and the author of the repo2docker
23+
repository doesn't need to deal with frustrating complexities like environment
24+
activation or requirements to work as expected on a JupyterHub.

docker/apt.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Unix utilities
2+
man
3+
man-db
4+
manpages-posix
5+
manpages-dev
6+
manpages-posix-dev
7+
rsync
8+
tree
9+
tmux
10+
htop
11+
12+
# Web utilities
13+
curl
14+
wget
15+
16+
# Editors
17+
nano
18+
jed
19+
emacs-nox
20+
vim
21+
22+
# Version control
23+
git
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ContentsManager": {
3+
"allow_hidden": true
4+
}
5+
}

docker/environment.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
channels:
2+
- "conda-forge"
3+
- "nodefaults"
4+
dependencies:
5+
- "python==3.13"
6+
- "jupyterlab>=4.4.2"
7+
8+
# Some cool extensions
9+
- "jupyterlab-favorites"
10+
- "jupyter-collaboration>=3,<4"
11+
- "jupyter-server-proxy"
12+
- "jupyterlab-myst"
13+
- "jupyterlab-geojson"
14+
- "nbdime"
15+
16+
# Python mainstays
17+
- "numpy"
18+
- "matplotlib"
19+
- "hvplot"
20+
- "pandas"
21+
- "scipy"
22+
- "xarray"
23+
24+
# geo
25+
- "gdal"
26+
- "geopandas"
27+
- "rasterio"
28+
- "rioxarray"
29+
- "shapely"
30+
- "pystac-client"
31+
32+
# geo viz
33+
- "jupytergis >=0.9.2"
34+
- "leafmap"
35+
- "folium"
36+
- "cartopy"
37+
- "geoviews"
38+
39+
# Publishing
40+
- "mystmd"
41+
- "typst"
42+
43+
# Testing and validation
44+
- "ruff"
45+
- "pre-commit"
46+
47+
# GitHub utilities
48+
- "gh"
49+
- "gh-scoped-creds"

docker/postBuild

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -l
2+
set -euo pipefail
3+
4+
# Put our custom Jupyter Server config into appropriate platform
5+
# This path is determined by looking at output of `jupyter --path` in the hub
6+
# We copy both to notebook server config and jupyter server config, because either can be
7+
# used in the JupyterHub.
8+
cp custom_jupyter_server_config.json ${NB_PYTHON_PREFIX}/etc/jupyter/jupyter_server_config.d/
9+
cp custom_jupyter_server_config.json ${NB_PYTHON_PREFIX}/etc/jupyter/jupyter_notebook_config.d/

docker/start

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Set any environment variables here
5+
# These are inherited by all processes, *except* RStudio
6+
7+
# Tell gh-scoped-creds which GitHub app to use for push access
8+
# See https://github.com/jupyterhub/gh-scoped-creds#github-app-configuration
9+
export GH_SCOPED_CREDS_CLIENT_ID="Iv1.bd27058fd393e285"
10+
export GH_SCOPED_CREDS_APP_URL="https://github.com/apps/cryocloud-github-access"
11+
12+
exec "$@"

0 commit comments

Comments
 (0)