Dockerfile.dev 4.3 KB

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