Dockerfile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. libpng-dev \
  21. openssh-server \
  22. autojump \
  23. language-pack-zh-hans \
  24. ttf-wqy-zenhei \
  25. libgl1-mesa-glx \
  26. libglib2.0-0 \
  27. locales &&\
  28. rm -rf /var/lib/apt/lists/*
  29. RUN locale-gen zh_CN.UTF-8
  30. RUN dpkg-reconfigure locales
  31. CMD ["supervisord", "-n"]
  32. FROM builder as builder1
  33. ENV PYTHON_VERSION 3
  34. RUN chsh -s `which zsh`
  35. RUN curl -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda${PYTHON_VERSION}-latest-Linux-x86_64.sh && \
  36. chmod +x ~/miniconda.sh && \
  37. ~/miniconda.sh -b -p /opt/conda && \
  38. rm ~/miniconda.sh
  39. RUN ln /opt/conda/bin/conda /usr/local/bin/conda
  40. RUN conda init zsh
  41. RUN conda install mamba -n base -c conda-forge
  42. RUN ln /opt/conda/bin/mamba /usr/local/bin/mamba && mamba init zsh
  43. FROM builder1 as builder2
  44. RUN apt-get update && apt-get install -y --no-install-recommends openssh-server && rm -rf /var/lib/apt/lists/*
  45. RUN mkdir /var/run/sshd
  46. RUN echo 'root:root' | chpasswd
  47. RUN sed -i 's/.*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config
  48. # SSH login fix. Otherwise user is kicked off after login
  49. RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
  50. RUN echo "\
  51. [program:sshd] \n\
  52. command=/usr/sbin/sshd -D\n\
  53. autorestart=True\n\
  54. autostart=True\n\
  55. redirect_stderr = true\n\
  56. " > /etc/supervisor/conf.d/sshd.conf
  57. EXPOSE 22
  58. FROM builder2 as builder3
  59. WORKDIR /workspace
  60. ADD environment.yml /environment.yml
  61. RUN sed -i 's#- paddlepaddle#- paddlepaddle-gpu==2.3.0.post110#g' /environment.yml && cat /environment.yml
  62. RUN mamba update -n base -c defaults conda -y && mamba env create -f /environment.yml && rm -rf /root/.cache
  63. # RUN /opt/conda/envs/py38/bin/python -m ipykernel install --name py38 --display-name "py38"
  64. # RUN echo "c.MultiKernelManager.default_kernel_name = 'py38'">>/root/.jupyter/jupyter_notebook_config.py
  65. RUN echo "\
  66. [program:be]\n\
  67. directory=/workspace\n\
  68. command=/opt/conda/envs/py38/bin/gunicorn server:app --workers 1 --worker-class=uvicorn.workers.UvicornWorker --bind 0.0.0.0:8080 --reload \n\
  69. autorestart=true\n\
  70. startretries=0\n\
  71. redirect_stderr=true\n\
  72. stdout_logfile=/var/log/be.log\n\
  73. stdout_logfile_maxbytes=0\n\
  74. " > /etc/supervisor/conf.d/be.conf
  75. ARG VERSION
  76. ENV USE_CUDA $VERSION
  77. Add . /workspace
  78. EXPOSE 8080
  79. # RUN mamba install -y jupyterlab -n base && mamba init zsh
  80. # RUN /opt/conda/bin/jupyter notebook --generate-config && \
  81. # echo "c.NotebookApp.password='argon2:\$argon2id\$v=19\$m=10240,t=10,p=8\$+zIUCF9Uk2FiCHlV8njX5A\$I5Mm/64DORArcXYTXWRVng'">>/root/.jupyter/jupyter_notebook_config.py
  82. # RUN mkdir -p /data && echo "\
  83. # [program:jupyter]\n\
  84. # directory=/data\n\
  85. # command=/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser \n\
  86. # autorestart=true\n\
  87. # startretries=0\n\
  88. # redirect_stderr=true\n\
  89. # stdout_logfile=/dev/stdout\n\
  90. # stdout_logfile_maxbytes=0\n\
  91. # " > /etc/supervisor/conf.d/jupyter.conf
  92. # EXPOSE 8888