Skip to content

Commit

Permalink
Merge pull request #52 from consideRatio/pr/hub-image
Browse files Browse the repository at this point in the history
image: add hub.jupytearth.org user environment image
  • Loading branch information
consideRatio authored Jun 1, 2021
2 parents f500d82 + 6e09a19 commit a5dd1b2
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 2 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# This GitHub workflow builds and pushes a user environment image to be used at
# hub.jupytearth.org. After having built the image, administrators can visit
# https://hub.jupytearth.org/services/configurator and set the image
#
name: Build image for hub.jupytearth.org

on:
pull_request:
paths:
- .github/workflows/build-image.yaml
- hub.jupytearth.org-image/**
push:
paths:
- .github/workflows/build-image.yaml
- hub.jupytearth.org-image/**

jobs:
build-image:
name: Build image
runs-on: ubuntu-20.04
steps:

- name: Checkout files in repo
uses: actions/checkout@v2

# ref: https://github.com/aws-actions/configure-aws-credentials
#
- name: Configure AWS credentials
if: github.event_name == 'push'
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ci-ecr

# ref: https://github.com/aws-actions/amazon-ecr-login
#
- name: Login to Amazon ECR
if: github.event_name == 'push'
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

# If we run out of disk space building this image, we can decomment this
# step to free up space for our GitHub Job runner.
#
# ref: https://github.com/easimon/maximize-build-space
#
# - name: Maximize build space
# uses: easimon/maximize-build-space@b4d02c14493a9653fe7af06cc89ca5298071c66e
# with:
# root-reserve-mb: 51200 # 50 GB
# # NOTE: We dump remaining space here to avoid
# # overriding our checked out repo folder.
# build-mount-path: /var/lib/docker/tmp
# remove-dotnet: "true"
# remove-haskell: "true"
# remove-android: "true"

- name: Test build image
run: |
docker build -t image-build-test ./hub.jupytearth.org-image
- name: Build, tag, and push image to Amazon ECR
if: github.event_name == 'push'
id: push
run: |
IMAGE_NAME=${{ steps.login-ecr.outputs.registry }}/jmte/user-env
IMAGE_TAG=$(git rev-parse --short "$GITHUB_SHA")
IMAGE=$IMAGE_NAME:$IMAGE_TAG
echo ::set-output "name=image-name::$IMAGE"
docker tag image-build-test $IMAGE .
docker push $IMAGE
- name: How to update hub.jupytearth.org to use this image
if: github.event_name == 'push'
run: |
echo "1. Visit https://hub.jupytearth.org/services/configurator as a JupyterHub admin."
echo "2. Configure to use this image: ${{ steps.push.outputs.image-name }}"
echo "3. Press save."
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ name: build-docs
on:
push:
branches:
- master
- master
paths-ignore:
- .github/workflows/build-image.yaml
- hub.jupytearth.org-image/**
pull_request:
branches:
- master
- master
paths-ignore:
- .github/workflows/build-image.yaml
- hub.jupytearth.org-image/**

jobs:
build-docs:
Expand Down
62 changes: 62 additions & 0 deletions hub.jupytearth.org-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# References regarding our base image:
# - ubuntu:20.04
# - pangeo/base-image definition: https://github.com/pangeo-data/pangeo-docker-images/blob/master/base-image
# - pangeo/pangeo-notebook definition: https://github.com/pangeo-data/pangeo-docker-images/tree/master/pangeo-notebook
# - pangeo/pangeo-notebook tags: https://hub.docker.com/r/pangeo/pangeo-notebook/tags
# - pangeo-notebook conda package: https://github.com/conda-forge/pangeo-notebook-feedstock/blob/master/recipe/meta.yaml
#
FROM pangeo/pangeo-notebook:2021.05.15
ARG DEBIAN_FRONTEND=noninteractive

# DISABLED: apt packages.
#
# Enable if we have a apt package we want to install!
#
# USER root
# RUN echo "Installing apt-get packages..." \
# && apt-get update \
# && apt-get install -y \
# gcc \
# && rm -rf /var/lib/apt/lists/*
# USER ${NB_USER}


# We only need to install packages not listed in this file already:
# https://github.com/pangeo-data/pangeo-docker-images/blob/master/pangeo-notebook/packages.txt
RUN echo "Installing conda packages..." \
&& mamba install -n ${CONDA_ENV} -y \
google-cloud-sdk \
&& echo "Installing conda packages complete!"


# We only need to install packages not listed in this file already:
# https://github.com/pangeo-data/pangeo-docker-images/blob/master/pangeo-notebook/packages.txt
RUN echo "Installing pip packages..." \
&& export PATH=${NB_PYTHON_PREFIX}/bin:${PATH} \
&& pip install --no-cache-dir \
jupyterlab==3.1.0a10 \
# ref: https://github.com/jupyterlab/jupyterlab
jupyterlab-link-share \
# ref: https://github.com/jupyterlab-contrib/jupyterlab-link-share
&& echo "Installing pip packages complete!"



# DISABLED: JupyterLab 2 extensions.
#
# If we want to install JupyterLab 2 based extensions we should first
# install node and add extensions here, but JupyterLab 3 extensions
# should preferably be installed as Python packages.
#
# RUN echo "Installing jupyterlab extensions..." \
# && export PATH=${NB_PYTHON_PREFIX}/bin:${PATH} \
# && jupyter labextension install -y --clean \
# @lckr/jupyterlab_variableinspector \
# && echo "Installing jupyterlab extensions complete!"



# Configure conda/mamba to create new environments within the home folder by
# default. This allows the environments to remain in between restarts of the
# container if only the home folder is persisted.
RUN conda config --system --prepend envs_dirs '~/.conda/envs'
17 changes: 17 additions & 0 deletions hub.jupytearth.org-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## What is this?

This is the home of the Dockerfile that builds into the base environment used in
https://hub.jupytearth.org. The cloud infrastructure declaration and Helm chart
configuration for https://hub.jupytearth.org lives in
https://github.com/2i2c-org/pilot-hubs/.

### How to work with this Dockerfile?

Whenever a pull request is made modifying the image, a GitHub Workflow will try
verify if it can successfully rebuild.

Whenever a pull request is merged modifying the image, a GitHub Workflow will
build and push the image and emit a message on how to update
https://hub.jupytearth.org to start making use of the new image. In short, it is
to visit https://hub.jupytearth.org/services/configurator and enter the image
name:tag which is described in the executed GitHub Workflow.

0 comments on commit a5dd1b2

Please sign in to comment.