# date updated: 2023-12-12
FROM debian:bookworm

USER root

RUN echo 'root:b23258585' | chpasswd
RUN useradd -m -d /home/alexlai -s /bin/bash -G sudo -u 1026 alexlai && \
    echo 'alexlai:alex1765' | chpasswd

# [Installing Miniconda](https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html)
RUN apt update && apt -y upgrade && \
    apt install -y fonts-noto-cjk wget && \
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && \
    bash /tmp/miniconda.sh -b -p /opt/conda && \
    rm /tmp/miniconda.sh

ENV PATH="/opt/conda/bin:$PATH"

# RUN conda update -n base -c defaults conda
# https://conda.org/blog/2023-07-28-july-2023-releases/
# latest release 23.11.0 https://github.com/conda/conda/releases
# RUN conda install conda=23.7.2
RUN conda install conda=23.11.0
# apt list -a python3 to list python version
RUN conda create -n myenv python=3.10

# Activate the Conda environment and install packages
# activate myenv: This is a command used by Conda to activate a virtual environment named "myenv." 
RUN echo "conda activate myenv" >> ~/.bashrc

# Install packages within the Conda environment
RUN /bin/bash -c "source activate myenv"
RUN conda install -c conda-forge jupyterhub 
RUN conda install -c conda-forge jupyterlab 
RUN conda install -c conda-forge jupyter_core
RUN conda install -c conda-forge notebook 
#
# the above is the most minimum packages
#
# R language, https://docs.anaconda.com/free/anaconda/reference/packages/r-language-pkg-docs/#r-language-packages-for-anaconda
#
RUN conda install -c conda-forge r r-essentials
RUN conda install -c conda-forge r-irkernel

#
# https://anaconda.org/krinsman/ijavascript
# 2023-12-10 OK
RUN conda install -c krinsman ijavascript
#
# ipykernel, failed
# 2023-12-10 OK
RUN conda install -c anaconda ipykernel
#
# using pip
#
RUN python3 -m pip install postgresql_kernel
#
# install nodejs, npm
#
# RUN apt install -y nodejs npm
# RUN npm install -g ijavascript &&  ijsinstall
#
# before you could use ijavacript, please from the hupyterhun terminal mode ans do
# $ ijsinstall  # have not found way to start it auto
#

#
# psycopg2, postgres_kernel and postgresql  failed
# RUN conda install -c anaconda psycopg2 
# RUN conda install -c anaconda postgres_kernel 
# RUN conda install -c anaconda postgresql
RUN conda install -c conda-forge ipython-sql
#
# for mongoDB
# Connecting to MongoDB
# https://enterprise-docs.anaconda.com/en/latest/data-science-workflows/data/mongodb.html
#
RUN conda install -c anaconda pymongo

# RUN    conda clean -afy
# 
# Setup mount point, for JupyterHub share folders
#
USER alexlai
RUN mkdir /home/alexlai/MuneTaka
RUN mkdir /home/alexlai/YuShei
RUN mkdir /home/alexlai/ChingYen
# 
RUN mkdir /home/alexlai/玉雪工作會報
RUN mkdir /home/alexlai/柯宅整休案
#
USER root

#
# using pip
#
# Skip the followings, they were installed by conda 
# RUN python3 -m pip install postgresql_kernel
#
# install nodejs, npm
#
# RUN apt install -y nodejs npm
# RUN npm install -g ijavascript &&  ijsinstall  
# 
# before you could use ijavacript, please from the hupyterhun terminal mode ans do
# ijsinstall  # have not found way to start it auto
# 


EXPOSE 8000

LABEL maintainer="alexlai@munetaka.me"

CMD ["jupyterhub"]

#
# Notes
#
# docker build --tag jupyterhub:debian_conda (--no-cache) ./
# docker run -it jupyterhub:debian_conda /bin/bash
# When you are in, test with `jupyterhub -h`, `configurable-http-proxy -h`
# docker run -d -p 42100:8000 --mount type=bind,source=/volume1/JupyterHub,target=/home/alexlai/JupyterHub --name jupyterhub jupyterhub:ubuntu_conda jupyterhub
#                       outside-port:inside-port
# docker run -d -p 42100:8000  --name jupyterhub jupyterhub:ubuntu_conda jupyterhub
# 
# docker ps
# docker stop (NAMES)
# docker rm  (NAMES)
#

[alexlai@orgpi58G ~]$ smbclient -L munetaka.me
Can't load /etc/samba/smb.conf - run testparm to debug it
Password for [WORKGROUP\alexlai]:

        Sharename       Type      Comment
        ---------       ----      -------
        homes           Disk      homes contains all users' home
        JupyterHub      Disk      JupyterHub Shared pholders
        MailPlus        Disk      Synology MailPlus
        pgAdmin4        Disk      pgAdmin4
        postgreSQL      Disk      
        test            Disk      
        web             Disk      System default shared folder
        web_packages    Disk      
        柯宅整休案 Disk      
        柯家新築案 Disk      
        IPC$            IPC       IPC Service ()
        home            Disk      Home directory of alexlai
SMB1 disabled -- no workgroup available