ยง2023-08-14

FROM ubuntu:jammy
# if you use debian:bullseye, some package will fail to run

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

RUN apt update && apt -y upgrade && \
    apt install -y wget && \
    apt install -y fonts-noto-cjk \
    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
RUN conda install conda=23.7.2
RUN conda create -n myenv python=3.10

# Activate the Conda environment and install packages
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
# failed
# RUN conda install -c krinsman ijavascript
#
# ipykernel, failed
#
# RUN conda install -c anaconda ipykernel
#
# 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
#
RUN conda install -c anaconda pymongo

# RUN    conda clean -afy
USER alexlai
RUN mkdir /home/alexlai/MuneTaka
RUN mkdir /home/alexlai/YuShei
RUN mkdir /home/alexlai/ChingYen

USER root

#
# 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
# 

EXPOSE 8000

LABEL maintainer="alexlai@munetaka.me"

CMD ["jupyterhub"]

#
# Notes
# 
# docker build --tag jupyterhub:ubuntu_conda (--no-cache) ./
# docker run -it jupyterhub:ubuntu_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@chingyennas:~/docker-proj/jupytyerHub/conda$ cat Dockerfile
FROM ubuntu:jammy

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

RUN apt update && apt -y upgrade && \
    apt install -y 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
RUN conda install conda=23.7.2
RUN conda create -n myenv python=3.10

# Activate the Conda environment and install packages
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
# failed
# RUN conda install -c krinsman ijavascript
#
# ipykernel, failed
#
# RUN conda install -c anaconda ipykernel
#
# 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
#
RUN conda install -c anaconda pymongo

# RUN    conda clean -afy
USER alexlai
RUN mkdir /home/alexlai/MuneTaka
RUN mkdir /home/alexlai/YuShei
RUN mkdir /home/alexlai/ChingYen

USER root

#
# 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
# 

EXPOSE 8000

LABEL maintainer="alexlai@munetaka.me"

CMD ["jupyterhub"]

#
# Notes
# 
# docker build --tag jupyterhub:ubuntu_conda (--no-cache) ./
# docker run -it jupyterhub:ubuntu_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)
#