Dockerfile.dev 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. FROM node:16.15.1-bullseye-slim AS builder-fe
  2. COPY docker_build/requirements.txt .
  3. RUN echo "deb http://mirror.nju.edu.cn/debian/ bullseye main contrib non-free" > /etc/apt/sources.list && \
  4. echo "deb http://mirror.nju.edu.cn/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \
  5. echo "deb http://mirror.nju.edu.cn/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list && \
  6. echo "deb http://mirror.nju.edu.cn/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list && \
  7. apt update && apt install -y python3 python3-pip python-is-python3 make \
  8. && pip config set global.index-url https://pypi.douban.com/simple \
  9. && pip install -U pip setuptools && pip install -r requirements.txt \
  10. && yarn config set registry https://registry.npm.taobao.org
  11. #https://registry.npmmirror.com
  12. COPY . /src/
  13. ENV PYTHONPATH=/src
  14. RUN cd /src && chmod a+x ./bdist_wheel.sh && ./bdist_wheel.sh
  15. FROM ubuntu:18.04 AS builder
  16. RUN sed -i 's#archive.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list \
  17. && sed -i 's#security.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list
  18. ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_ALL=zh_CN.UTF-8 DEBIAN_FRONTEND=noninteractive
  19. RUN rm -rf /etc/apt/sources.list.d/ && apt update
  20. RUN apt-get update && apt-get install -y --no-install-recommends \
  21. supervisor \
  22. iputils-ping \
  23. wget \
  24. zsh \
  25. build-essential \
  26. cmake \
  27. git \
  28. curl \
  29. vim \
  30. ca-certificates \
  31. libjpeg-dev \
  32. zip \
  33. unzip \
  34. libpng-dev \
  35. openssh-server \
  36. autojump \
  37. language-pack-zh-hans \
  38. ttf-wqy-zenhei \
  39. libgl1-mesa-glx \
  40. libglib2.0-0 \
  41. locales &&\
  42. rm -rf /var/lib/apt/lists/*
  43. RUN locale-gen zh_CN.UTF-8
  44. RUN dpkg-reconfigure locales
  45. CMD ["supervisord", "-n"]
  46. FROM builder as builder1
  47. ENV PYTHON_VERSION 3
  48. RUN chsh -s `which zsh`
  49. RUN curl -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda${PYTHON_VERSION}-latest-Linux-x86_64.sh && \
  50. chmod +x ~/miniconda.sh && \
  51. ~/miniconda.sh -b -p /opt/conda && \
  52. rm ~/miniconda.sh
  53. RUN ln /opt/conda/bin/conda /usr/local/bin/conda
  54. RUN conda init zsh
  55. RUN conda install mamba -n base -c conda-forge
  56. RUN ln /opt/conda/bin/mamba /usr/local/bin/mamba && mamba init zsh
  57. FROM builder1 as builder2
  58. WORKDIR /workspace
  59. COPY --from=builder-fe /src/dist dist
  60. RUN /opt/conda/bin/pip install dist/*.whl -i https://pypi.douban.com/simple
  61. RUN /opt/conda/bin/pip install jupyterlab-language-pack-zh-CN -i https://pypi.douban.com/simple
  62. RUN mamba install nodejs
  63. # password 'sx'
  64. RUN /opt/conda/bin/jupyter lab --generate-config && \
  65. echo "c.NotebookApp.password='argon2:\$argon2id\$v=19\$m=10240,t=10,p=8\$+zIUCF9Uk2FiCHlV8njX5A\$I5Mm/64DORArcXYTXWRVng'">>/root/.jupyter/jupyter_lab_config.py
  66. FROM builder2 as builder3
  67. RUN apt-get update && apt-get install -y --no-install-recommends openjdk-8-jdk krb5-user
  68. RUN mamba install nodejs sparkmagic pyhive thrift sasl thrift_sasl -y
  69. # RUN /opt/conda/bin/pip install sparkmagipc -i https://pypi.douban.com/simple
  70. ENV PATH /opt/conda/bin/:$PATH
  71. RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension
  72. RUN cd /opt/conda/lib/python3.9/site-packages/ \
  73. && jupyter-kernelspec install sparkmagic/kernels/sparkkernel --user \
  74. && jupyter-kernelspec install sparkmagic/kernels/pysparkkernel --user\
  75. && /opt/conda/bin/jupyter serverextension enable --py sparkmagic
  76. RUN /opt/conda/bin/pip install dist/*.whl -i https://pypi.douban.com/simple
  77. ADD confs/krb5.conf /etc/
  78. ADD confs/config.json ~/.sparkmagic/config.json
  79. ADD emr-5xjsy31f_ailab.keytab /
  80. # RUN kinit -k -t emr-5xjsy31f_ailab.keytab ailab
  81. RUN echo "\
  82. [program:jupyter]\n\
  83. directory=/workspace\n\
  84. command=/bin/bash -c 'kinit -k -t /emr-5xjsy31f_ailab.keytab ailab && /opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser' \n\
  85. autorestart=true\n\
  86. startretries=0\n\
  87. redirect_stderr=true\n\
  88. stdout_logfile=/var/log/jupyter.log\n\
  89. stdout_logfile_maxbytes=50MB\n\
  90. " > /etc/supervisor/conf.d/jupyter.conf
  91. EXPOSE 8888