Dockerfile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. FROM nvidia/cuda:11.0-cudnn8-devel-ubuntu18.04 AS builder
  2. RUN sed -i 's#archive.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list \
  3. && sed -i 's#security.ubuntu.com#mirrors.aliyun.com#g' /etc/apt/sources.list
  4. ENV LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_ALL=zh_CN.UTF-8 DEBIAN_FRONTEND=noninteractive
  5. RUN rm -rf /etc/apt/sources.list.d/ && apt update
  6. RUN apt-get update && apt-get install -y --no-install-recommends \
  7. supervisor \
  8. iputils-ping \
  9. wget \
  10. zsh \
  11. build-essential \
  12. cmake \
  13. git \
  14. curl \
  15. vim \
  16. ca-certificates \
  17. libjpeg-dev \
  18. zip \
  19. unzip \
  20. tmux \
  21. libpng-dev \
  22. openssh-server \
  23. autojump \
  24. language-pack-zh-hans \
  25. ttf-wqy-zenhei \
  26. libgl1-mesa-glx \
  27. libglib2.0-0 \
  28. locales &&\
  29. rm -rf /var/lib/apt/lists/*
  30. RUN locale-gen zh_CN.UTF-8
  31. RUN dpkg-reconfigure locales
  32. CMD ["supervisord", "-n"]
  33. FROM builder as builder1
  34. ENV PYTHON_VERSION 3
  35. RUN chsh -s `which zsh`
  36. RUN curl -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda${PYTHON_VERSION}-latest-Linux-x86_64.sh && \
  37. chmod +x ~/miniconda.sh && \
  38. ~/miniconda.sh -b -p /opt/conda && \
  39. rm ~/miniconda.sh
  40. RUN ln /opt/conda/bin/conda /usr/local/bin/conda
  41. RUN conda init zsh
  42. RUN conda install mamba -n base -c conda-forge
  43. RUN ln /opt/conda/bin/mamba /usr/local/bin/mamba && mamba init zsh
  44. FROM builder1 as builder2
  45. RUN apt-get update && apt-get install -y --no-install-recommends openssh-server && rm -rf /var/lib/apt/lists/*
  46. RUN mkdir /var/run/sshd
  47. RUN echo 'root:root' | chpasswd
  48. RUN sed -i 's/.*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config
  49. # SSH login fix. Otherwise user is kicked off after login
  50. RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
  51. RUN echo "\
  52. [program:sshd] \n\
  53. command=/usr/sbin/sshd -D\n\
  54. autorestart=True\n\
  55. autostart=True\n\
  56. redirect_stderr = true\n\
  57. " > /etc/supervisor/conf.d/sshd.conf
  58. EXPOSE 22
  59. FROM builder2 as builder3
  60. WORKDIR /workspace
  61. #ADD environment.yml /environment.yml
  62. RUN echo "\
  63. name: py38\n\
  64. channels:\n\
  65. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ # Anocanda清华镜像\n\
  66. - defaults\n\
  67. - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/\n\
  68. dependencies:\n\
  69. - python=3.8\n\
  70. - ipython\n\
  71. - pip\n\
  72. - pip:\n\
  73. - cmake\n\
  74. - opencv-python\n\
  75. - cython\n\
  76. - paddleocr==2.5.0.3\n\
  77. - paddlehub==2.2.0\n\
  78. - fastapi==0.79.0\n\
  79. - uvicorn\n\
  80. - jinja2\n\
  81. - aiofiles\n\
  82. - python-multipart\n\
  83. - requests\n\
  84. - cpca\n\
  85. - gunicorn\n\
  86. - -i https://mirror.baidu.com/pypi/simple\n\
  87. - paddlepaddle-gpu==2.3.0.post110\n\
  88. - -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html\n\
  89. prefix: /opt/conda/envs/py38\n\
  90. " > /environment.yml
  91. RUN mamba update -n base -c defaults conda -y && mamba env create -f /environment.yml && rm -rf /root/.cache
  92. RUN echo "\
  93. [program:be]\n\
  94. directory=/workspace\n\
  95. command=/opt/conda/envs/py38/bin/gunicorn server:app --workers 1 --worker-class=uvicorn.workers.UvicornWorker --bind 0.0.0.0:8080 --reload \n\
  96. autorestart=true\n\
  97. startretries=0\n\
  98. redirect_stderr=true\n\
  99. stdout_logfile=/var/log/be.log\n\
  100. stdout_logfile_maxbytes=0\n\
  101. " > /etc/supervisor/conf.d/be.conf
  102. ARG VERSION
  103. ENV USE_CUDA $VERSION
  104. #Add . /workspace
  105. EXPOSE 8080
  106. # RUN mamba install -y jupyterlab -n base && mamba init zsh
  107. # RUN /opt/conda/bin/jupyter notebook --generate-config && \
  108. # echo "c.NotebookApp.password='argon2:\$argon2id\$v=19\$m=10240,t=10,p=8\$+zIUCF9Uk2FiCHlV8njX5A\$I5Mm/64DORArcXYTXWRVng'">>/root/.jupyter/jupyter_notebook_config.py
  109. # RUN mkdir -p /data && echo "\
  110. # [program:jupyter]\n\
  111. # directory=/data\n\
  112. # command=/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser \n\
  113. # autorestart=true\n\
  114. # startretries=0\n\
  115. # redirect_stderr=true\n\
  116. # stdout_logfile=/dev/stdout\n\
  117. # stdout_logfile_maxbytes=0\n\
  118. # " > /etc/supervisor/conf.d/jupyter.conf
  119. # EXPOSE 8888