-
-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
119 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Dockerfile for binder | ||
# Reference: https://mybinder.readthedocs.io/en/latest/tutorials/dockerfile.html | ||
|
||
# Pull the Sage docker image | ||
FROM ghcr.io/sagemath/sage/sage-ubuntu-focal-standard-with-targets-optional:dev | ||
|
||
USER root | ||
|
||
# These lines are here to remove warnings | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV DEBCONF_NOWARNINGS="yes" | ||
|
||
# Install jupyterlab to the system | ||
RUN apt-get update | ||
RUN apt-get install -y apt-utils | ||
RUN apt-get install -y python3-pip | ||
RUN python3 -m pip install --no-warn-script-location jupyterlab | ||
|
||
# Create user "alice" whose uid is 1000 | ||
ARG NB_USER=alice | ||
ARG NB_UID=1000 | ||
ENV NB_USER ${NB_USER} | ||
ENV NB_UID ${NB_UID} | ||
ENV HOME /home/${NB_USER} | ||
RUN adduser --disabled-password --gecos "Default user" --uid ${NB_UID} ${NB_USER} | ||
|
||
# Prepare for building Sage | ||
ENV PR_REPO https://github.com/REPO_NAME | ||
ENV PR_BRANCH BRANCH_NAME | ||
RUN apt-get install -y git | ||
|
||
# Build Sage | ||
WORKDIR /sage | ||
RUN export PATH="/sage/build/bin:$PATH" | ||
RUN git config --global user.email ${NB_USER}@wonderland | ||
RUN git config --global user.name ${NB_USER} | ||
RUN git config --global --add safe.directory $(pwd) | ||
RUN pwd | ||
COPY .gitignore /sage/.gitignore | ||
RUN if [ ! -d .git ]; then git init && git add -A; fi | ||
RUN git fetch ${PR_REPO} ${PR_BRANCH} | ||
RUN git checkout -f FETCH_HEAD | ||
RUN ./bootstrap && ./configure --enable-build-as-root && make -j4 | ||
|
||
# Make sure the contents of our repo are in ${HOME} | ||
COPY notebooks/* ${HOME}/ | ||
RUN chown -R ${NB_UID} ${HOME} | ||
|
||
# Switch to the user | ||
USER ${NB_USER} | ||
|
||
# Install jupyterlab to Sage | ||
RUN /sage/sage -pip install --no-warn-script-location jupyterlab | ||
|
||
# This is where kernels are installed | ||
RUN mkdir -p $(jupyter --data-dir)/kernels | ||
|
||
# Install sagemath kernel | ||
RUN ln -s /sage/venv/share/jupyter/kernels/sagemath $(jupyter --data-dir)/kernels | ||
|
||
# Start in the home directory of the user | ||
WORKDIR /home/${NB_USER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Create Binder branch | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
create-branch: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Create binder branch | ||
run: | | ||
set -ex | ||
REPO_NAME=${{ github.repository }} | ||
BRANCH_NAME=${GITHUB_REF#refs/heads/} | ||
BINDER_REPO_NAME=${REPO_NAME} | ||
BINDER_BRANCH_NAME=${BRANCH_NAME}-binder | ||
cp .github/workflows/binder-dockerfile Dockerfile | ||
sed -i 's/REPO_NAME/'$(echo "${REPO_NAME}" | sed 's/\//\\\//g')'/' Dockerfile | ||
sed -i 's/BRANCH_NAME/'$(echo "${BRANCH_NAME}" | sed 's/\//\\\//g')'/' Dockerfile | ||
sed -i 's/sagemath\/sage-binder-env\/master/'$(echo "${BINDER_REPO_NAME}/${BINDER_BRANCH_NAME}" | sed 's/\//\\\//g')'/' README.md | ||
if [ ! -d .git ]; then git init; fi | ||
if [ ! -d notebooks ]; then mkdir notebooks && touch notebooks/my_favorite_notebooks.md; fi | ||
git config --global user.email alice@wonderland | ||
git config --global user.name alice | ||
git config --global --add safe.directory $(pwd) | ||
git checkout -b $BINDER_BRANCH_NAME | ||
git add -A | ||
git commit -a -m "Init" | ||
git push origin $BINDER_BRANCH_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters