Skip to content

Commit

Permalink
add devhub - jupyterhub (#3)
Browse files Browse the repository at this point in the history
* add devhub
* debug hub
  • Loading branch information
haobibo authored Mar 12, 2024
1 parent 8c3b500 commit 4836994
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 18 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ jobs:
- run: |
source ./tool.sh && build_image app-clash latest docker_app_clash/Dockerfile && push_image
## DevHub
qpod_dev-hub:
name: 'dev-hub'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh
build_image dev-hub latest docker_dev_box/hub.Dockerfile \
--build-arg "BASE_IMG=node" \
--build-arg "ARG_PROFILE_JUPYTER=hub"
push_image
## DevBox - base
qpod_base-dev:
name: 'developer,base-dev'
Expand All @@ -44,7 +57,7 @@ jobs:
- uses: actions/checkout@v4
- run: |
source ./tool.sh && free_diskspace
build_image base-dev latest docker_devbox/Dockerfile \
build_image base-dev latest docker_dev_box/Dockerfile \
--build-arg "BASE_IMG=node" \
--build-arg "ARG_PROFILE_JUPYTER=base,kernels,extensions" \
--build-arg "ARG_PROFILE_VSCODE=base"
Expand All @@ -57,7 +70,7 @@ jobs:
- uses: actions/checkout@v4
- run: |
source ./tool.sh && free_diskspace
build_image full-stack-dev latest docker_devbox/Dockerfile \
build_image full-stack-dev latest docker_dev_box/Dockerfile \
--build-arg "BASE_IMG=full-stack" \
--build-arg "ARG_PROFILE_JUPYTER=base,kernels,extensions" \
--build-arg "ARG_PROFILE_VSCODE=base"
Expand All @@ -70,7 +83,7 @@ jobs:
- uses: actions/checkout@v4
- run: |
source ./tool.sh && free_diskspace
build_image cuda-dev latest docker_devbox/Dockerfile \
build_image cuda-dev latest docker_dev_box/Dockerfile \
--build-arg "BASE_IMG=core-cuda" \
--build-arg "ARG_PROFILE_JUPYTER=base,kernels,extensions" \
--build-arg "ARG_PROFILE_VSCODE=base"
Expand Down
4 changes: 2 additions & 2 deletions docker_devbox/Dockerfile → docker_dev_box/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM ${BASE_NAMESPACE:+$BASE_NAMESPACE/}${BASE_IMG}

LABEL maintainer="[email protected]"

# base,kernels,extensions
# base,kernels,extensions,hub
ARG ARG_PROFILE_JUPYTER=base

# base
Expand All @@ -16,7 +16,7 @@ ARG ARG_KEEP_NODEJS=true

COPY work /opt/utils/

# Setup Jupyter: Basic Configurations and Extensions...
# Setup Jupyter: Basic Configurations and Extensions
RUN mkdir -pv /opt/conda/etc/jupyter/ \
&& mv /opt/utils/etc_jupyter/* /opt/conda/etc/jupyter/ && rm -rf /opt/utils/etc_jupyter \
&& mv /opt/utils/start-*.sh /usr/local/bin/ && chmod +x /usr/local/bin/start-*.sh \
Expand Down
41 changes: 41 additions & 0 deletions docker_dev_box/hub.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Distributed under the terms of the Modified BSD License.

ARG BASE_NAMESPACE
ARG BASE_IMG="node"
FROM ${BASE_NAMESPACE:+$BASE_NAMESPACE/}${BASE_IMG}

LABEL maintainer="[email protected]"

# base,kernels,extensions,hub
ARG ARG_PROFILE_JUPYTER=hub

ARG ARG_KEEP_NODEJS=true

COPY work /opt/utils/

# Setup JupyterHub
RUN source /opt/utils/script-devbox-jupyter.sh \
&& for profile in $(echo $ARG_PROFILE_JUPYTER | tr "," "\n") ; do ( setup_jupyter_${profile} || true ) ; done

# If not keeping NodeJS, remove NoedJS to reduce image size, and install Traefik instead
RUN ${ARG_KEEP_NODEJS:-true} || ( \
echo "Removing Node/NPM..." && rm -rf /usr/bin/node /usr/bin/npm /usr/bin/npx /opt/node \
&& echo "Installing Traefik to server as proxy:" && source /opt/utils/script-setup.sh && setup_traefik \
)

# Clean up and display components version information...
RUN source /opt/utils/script-utils.sh && install__clean && list_installed_packages

EXPOSE 8888

ENTRYPOINT ["tini", "-g", "--"]
CMD ["jupyterhub"]

# '-c' option make bash commands are read from string.
# If there are arguments after the string, they are assigned to the positional parameters, starting with $0.
# '-o pipefail' prevents errors in a pipeline from being masked.
# If any command in a pipeline fails, that return code will be used as the return code of the whole pipeline.
# '--login': make bash first reads and executes commands from the file /etc/profile, if that file exists.
# After that, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"]
WORKDIR "/opt/jupyterhub"
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,14 @@ setup_jupyter_extensions() {
&& echo "@ Jupyter Lab Extension list: " && jupyter labextension list \
&& echo "@ Jupyter Notebook Extension list: " && jupyter notebook extension list
}


setup_jupyter_hub() {
# ref1: https://github.com/jupyterhub/jupyterhub
# ref2: https://github.com/jupyterhub/jupyterhub/blob/main/Dockerfile
npm install -g npm configurable-http-proxy \
&& pip install -Uq oauthenticator jupyterhub-ldapauthenticator jupyterhub-kerberosauthenticator \
&& pip install -Uq dockerspawner jupyterhub-kubespawner jupyterhub-systemdspawner wrapspawner \
&& pip install -Uq psutil pycurl jupyter_client jupyterhub \
&& echo "@ JupyterHub version: $(jupyterhub --version)"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 0 additions & 13 deletions tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,6 @@ clear_images() {
docker image prune --force && docker images ;
}

setup_docker_syncer() {
ARCH="amd64" \
&& SYNCER_VERSION="$(curl -sL https://github.com/AliyunContainerService/image-syncer/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[.\d]+')" \
&& SYNCER_URL="https://github.com/AliyunContainerService/image-syncer/releases/download/v${SYNCER_VERSION}/image-syncer-v${SYNCER_VERSION}-linux-${ARCH}.tar.gz" \
&& echo "Downloading image-syncer from: ${SYNCER_URL}" \
&& curl -o /tmp/image_syncer.tgz -sL ${SYNCER_URL} \
&& mkdir -pv /tmp/image_syncer && tar -zxvf /tmp/image_syncer.tgz -C /tmp/image_syncer \
&& sudo chmod +x /tmp/image_syncer/image-syncer \
&& sudo mv /tmp/image_syncer/image-syncer /usr/bin/ \
&& rm -rf /tmp/image_syncer* \
&& echo "@ image-syncer installed to: $(which image-syncer)"
}


remove_folder() {
sudo du -h -d1 "$1" || true ;
Expand Down

0 comments on commit 4836994

Please sign in to comment.