FROM ubuntu:20.04

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  python3-dev python3-pip python3-setuptools openssh-server \
  && sed -i "s/.*PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config \
  && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN ln -sf /usr/bin/python3 /usr/bin/python \
  && ln -sf /usr/bin/pip3 /usr/bin/pip  \
  &&  pip install --no-cache-dir -i https://pypi.doubanio.com/simple/ -U pip \
  && mkdir -p /etc/jupyter /ai

COPY run.sh /usr/local/bin/
COPY notebook /usr/local/bin/
COPY jupyter_notebook_config.py /etc/jupyter/

RUN chmod +x /usr/local/bin/run.sh /usr/local/bin/notebook \
  && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  && pip install --no-cache-dir notebook tensorboard

EXPOSE 22 8888

ENV LANG=C.UTF-8
ENV SHELL=/bin/bash
WORKDIR /ai

CMD ["run.sh"]