ยง2023-8-12

#
# 2023-08-12, synologyNas@chingyen.com.tw
# 
FROM ubuntu:22.04 AS final

# Update packages and install necessary tools
RUN apt-get update && \
    apt-get install -y python3 python3-pip nodejs npm
RUN apt install -y python3.10-venv
# Install JupyterHub using pip and npm
RUN python3 -m pip install jupyterhub
RUN npm install -g configurable-http-proxy

# Create and activate the virtual environment
RUN python3 -m venv /venv
SHELL ["/bin/bash", "-o", "pipefail", "-c", "source /venv/bin/activate"]

# Install JupyterLab, notebook, kernels, and other dependencies
RUN python3 -m pip install jupyterlab notebook ipykernel ijavascript postgres_kernel IRkernel jupyter-c-kernel iredis-kernel

# Install Adobe Asian Fonts
RUN apt-get install -y fonts-noto-cjk

# Add user alexlai
RUN groupadd -r wheel && \
    useradd -m -d /home/alexlai -s /bin/bash -G wheel -u 1026 alexlai && \
    getent passwd alexlai && \
    echo 'alexlai:alex1765' | chpasswd

# Create a directory for JupyterHub's shared file folder
RUN mkdir /home/alexlai/JupyterHub

# Expose port for JupyterHub
EXPOSE 8000

LABEL maintainer="alexlai@munetaka.me"

# Start JupyterHub when the container runs
CMD ["/bin/bash", "-c", "source /venv/bin/activate && jupyterhub"]

#
# Notes
# 
# sudo docker build --tag jupyterhub:ubuntu-22.04_x86_64 (--no-cache) ./
# sudo docker run -it jupyterhub:ubuntu-22.04_x86_64 (/bin/bash)
# sudo docker run -d -p 42103:8000 --mount type=bind,source=/volume1/YsUbuntuJupyterHubProj,target=/home/alexlai/JupyterHub --name jupyterhub jupyterhub:ubuntu-22.04_x86_64 jupyterhub
#                       outside-port:inside-port
# docker ps
# docker stop (NAMES)
# docker rm  (NAMES)
#

$ sudo docker build --tag jupyterhub:ubuntu-22.04_x86_64 (--no-cache) ./ then test with

Test with,

$ sudo docker run -d -p 42103:8000 --mount type=bind,source=/volume1/YsUbuntuJupyterHubProj,target=/home/alexlai/JupyterHub --name jupyterhub jupyterhub:ubuntu-22.04_x86_64 jupyterhub

But I can not even curl at port 42103

  1. Dockerfile, not working
#
# 2023-08-12, synologyNas@chingyen.com.tw
# 
ARG BASE_IMAGE=archlinux         
FROM $BASE_IMAGE AS final

# update
RUN pacman -Sy
#
# Insatll python3
#
RUN yes | pacman -S python     
RUN yes | pacman -S python-pip # pip and pip3 installed
#
# nodejs and npm
#
RUN yes | pacman -S nodejs npm
#
# install jupyterhub using pip and npm
# https://jupyterhub.readthedocs.io/en/stable/quickstart.html#installation
#RUN yes | pacman -S jupyterhub # no good
#
# Creste Virtual Enviroment
#
RUN python3 -m venv /venv
#
# Activate the virtual environment
SHELL ["/bin/bash", "-o", "pipefail", "-c", "source /venv/bin/activate"]
#
RUN python3 -m pip install jupyterhub
# RUN conda install -c conda-forge jupyterhub
RUN npm install -g configurable-http-proxy
RUN python3 -m pip install jupyterlab notebook  # needed if running the notebook servers in the same environment
RUN python3 -m pip install ipykernel
RUN python3 -m pip install ijavascript  
RUN python3 -m pip install postgres_kernel
RUN python3 -m pip install  IRkernel # R3 kernel for Jupyter Notebook
RUN python3 -m pip nstall jupyter-c-kernel # minimal c compiler
RUN python3 -m pip install iredis-kernel
#
# Install Adbobe Asian Fonts
#
RUN yes | pacman -S adobe-source-han-serif-cn-fonts adobe-source-han-serif-jp-fonts adobe-source-han-serif-kr-fonts adobe-source-han-serif-otc-fonts adobe-source-han-serif-tw-fonts
#
# add user alexlai
#
# -r: create system account, -m create home directory
RUN groupadd -r wheel
RUN useradd -m -d /home/alexlai -s /bin/bash -G wheel -u 1026 alexlai
# SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN getent passwd alexlai
RUN echo 'alexlai:alex1765' | chpasswd
#
# mkdir JupyterHub the mount poiny of shared file folder
#
RUN mkdir /home/alexlai/JupyterHub
#
#
# install redis
#

EXPOSE 8000

LABEL maintainer="alexlai@munetaka.me"

CMD ["/bin/bash", "-c", "source /venv/bin/activate && jupyterhub"]
#
# Notes
# 
# sudo docker build --tag jupyterhub:ubuntu-22.04_x86_64 (--no-cache) ./
# sudo docker run -it jupyterhub:ubuntu-22.04_x86_64 (/bin/bash)
# sudo docker run -d -p 42100:8000 --mount type=bind,source=/volume1/JupyterHub,target=/home/alexlai/JupyterHub --name jupyterhub jupyterhub:ubuntu-22.04_x86_64 jupyterhub
#                       outside-port:inside-port
# docker ps
# docker stop (NAMES)
# docker rm  (NAMES)
#
  1. 2023-01-18 old Dockerfile
#
# 2023-01-18
# 
ARG BASE_IMAGE=archlinux         
FROM $BASE_IMAGE AS builder

# update
RUN pacman -Sy
#
# Insatll python3
#
RUN yes | pacman -S python3     
RUN yes | pacman -S python-pip # pip and pip3 installed
#
# nodejs and npm
#
RUN yes | pacman -S nodejs npm
#
# install jupyterhub using pip and npm
# https://jupyterhub.readthedocs.io/en/stable/quickstart.html#installation
#RUN yes | pacman -S jupyterhub # no good
# 
RUN python3 -m pip install jupyterhub
RUN npm install -g configurable-http-proxy
RUN python3 -m pip install jupyterlab notebook  # needed if running the notebook servers in the same environment
#
# Install Adbobe Asian Fonts
#
RUN yes | pacman -S adobe-source-han-serif-cn-fonts adobe-source-han-serif-jp-fonts adobe-source-han-serif-kr-fonts adobe-source-han-serif-otc-fonts adobe-source-han-serif-tw-fonts
#
# add user alexlai
#
# -r: create system account, -m create home directory
RUN useradd -m -d /home/alexlai -s /bin/bash -G wheel -u 1026 alexlai
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN echo 'alexlai:alex1765' | chpasswd
#
# mkdir JupyterHub the mount poiny of shared file folder
#
RUN mkdir /home/alexlai/JupyterHub
#
#
# install redis
#

#
# install postgresql_kernel
# 
RUN python3 -m pip install postgresql_kernel

EXPOSE 8000

LABEL maintainer="alexlai@munetaka.me"

CMD ["jupyterhub"]
#
# Notes
# 
# sudo docker build --tag jupyterhub:archlinux_x86_64_UTF-8 (--no-cache) ./
# sudo docker run -it jupyterhub:archlinux_x86_64_UTF-8 
# sudo docker run -d -p 42100:8000 --mount type=bind,source=/volume1/Jupyterhub,target=/home/alexlai --name jupyterhub jupyterhub:archlinux_x86_64_UTF-8 jupyterhub
#                       outside-port:inside-port
# docker ps
# docker stop (NAMES)
# docker rm  (NAMES)
#
# 2023-04-17
# 
ARG BASE_IMAGE=archlinux         
FROM $BASE_IMAGE AS builder

# update
RUN pacman -Sy
#
# Insatll python3
#
RUN yes | pacman -S python3     
RUN yes | pacman -S python-pip # pip and pip3 installed
#
# nodejs and npm
#
RUN yes | pacman -S nodejs npm
#
# install jupyterhub using pip and npm
# https://jupyterhub.readthedocs.io/en/stable/quickstart.html#installation
#RUN yes | pacman -S jupyterhub # no good
# 
RUN python3 -m pip install jupyterhub
RUN npm install -g configurable-http-proxy
RUN python3 -m pip install jupyterlab notebook  # needed if running the notebook servers in the same environment
#
# Install Adbobe Asian Fonts
#
RUN yes | pacman -S adobe-source-han-serif-cn-fonts adobe-source-han-serif-jp-fonts adobe-source-han-serif-kr-fonts adobe-source-han-serif-otc-fonts adobe-source-han-serif-tw-fonts
#
# add user alexlai
#
# -r: create system account, -m create home directory
RUN useradd -m -d /home/alexlai -s /bin/bash -G wheel -u 1026 alexlai
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN echo 'alexlai:alex1765' | chpasswd
#
# mkdir JupyterHub the mount poiny of shared file folder
#
RUN mkdir /home/alexlai/JupyterHub
#
#
# install redis
#

EXPOSE 8000

LABEL maintainer="alexlai@munetaka.me"

CMD ["jupyterhub"]
#
# Notes
# 
# sudo docker build --tag jupyterhub:archlinux_x86_64_UTF-8 (--no-cache) ./
# sudo docker run -it jupyterhub:archlinux_x86_64_UTF-8 (/bin/bash)
# sudo docker run -d -p 42100:8000 --mount type=bind,source=/volume1/JupyterHub,target=/home/alexlai/JupyterHub --name jupyterhub jupyterhub:archlinux_x86_64_UTF-8 jupyterhub
#                       outside-port:inside-port
# docker ps
# docker stop (NAMES)
# docker rm  (NAMES)