FROM ubuntu:22.04

USER root

# general update and packages
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -y upgrade && \
    apt-get install -y sudo binutils git && \
    apt-get install -y python3-pip &&  \
    apt-get clean && rm -rf /var/lib/apt/lists/* && \
    pip3 install --no-cache-dir --upgrade pip

# python packages for data analysis
RUN pip3 install --no-cache-dir numpy scipy matplotlib \
  pandas seaborn \
  jupyterlab \
  uncertainties \
  iminuit \
  kafe2 \
  PhyPraKit \
  vector 

# Create cgda user, include as sudoer
ARG USR=dausr
ARG UID=12345
ARG GID=100
RUN adduser --disabled-password --gecos "" -u ${UID} --gid ${GID} ${USR}
RUN echo "${USR} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers

WORKDIR /home/${USR}
ENV HOME /home/${USR}
COPY dot-bashrc $HOME/.bashrc
COPY . $HOME
RUN chown --recursive $USR $HOME 
RUN chgrp --recursive users $HOME 

EXPOSE 8888

USER $USR
ENV SHELL /bin/bash

CMD jupyter-lab --ip 0.0.0.0 --no-browser

## to execute, start with
# docker run -p 8888:8888 cgda:22.04
