Dockerfile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. FROM ubuntu:18.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. ENV TZ Asia/Shanghai
  32. RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
  33. echo "Asia/Shanghai" > /etc/timezone
  34. CMD ["supervisord", "-n"]
  35. FROM builder as builder1
  36. ENV PYTHON_VERSION 3
  37. RUN chsh -s `which zsh`
  38. # RUN curl -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda${PYTHON_VERSION}-latest-Linux-x86_64.sh && \
  39. # chmod +x ~/miniconda.sh && \
  40. # ~/miniconda.sh -b -p /opt/conda && \
  41. # rm ~/miniconda.sh
  42. ADD assets/conda/miniconda.sh /miniconda.sh
  43. RUN chmod +x /miniconda.sh && \
  44. /miniconda.sh -b -p /opt/conda && \
  45. rm /miniconda.sh
  46. RUN ln /opt/conda/bin/conda /usr/local/bin/conda
  47. RUN conda init zsh
  48. RUN conda install mamba -n base -c conda-forge
  49. # RUN conda install libarchive==3.6.2 -n base -c conda-forge
  50. RUN ln /opt/conda/bin/mamba /usr/local/bin/mamba && mamba init zsh
  51. FROM builder1 as builder2
  52. ENV WORKDIR /workspace
  53. WORKDIR ${WORKDIR}
  54. ADD environment.yml /environment.yml
  55. RUN mamba update -n base -c defaults conda -y && mamba env create -f /environment.yml && rm -rf /root/.cache
  56. # RUN /opt/conda/envs/py38/bin/python -m ipykernel install --name py38 --display-name "py38"
  57. # RUN echo "c.MultiKernelManager.default_kernel_name = 'py38'">>/root/.jupyter/jupyter_notebook_config.py
  58. RUN echo "\
  59. [program:be]\n\
  60. directory=%(ENV_WORKDIR)s\n\
  61. command= /opt/conda/envs/py38/bin/gunicorn server:app -b 0.0.0.0:8080 --reload -k utils.r_uvicorn_worker.RestartableUvicornWorker -w 2 \n\
  62. autorestart=true\n\
  63. startretries=1000\n\
  64. redirect_stderr=true\n\
  65. stdout_logfile=/var/log/be.log\n\
  66. stdout_logfile_maxbytes=50MB\n\
  67. environment=PYTHONUNBUFFERED=1\n\
  68. " > /etc/supervisor/conf.d/be.conf
  69. EXPOSE 8080
  70. RUN echo "\
  71. [program:cron]\n\
  72. directory=%(ENV_WORKDIR)s\n\
  73. command= /opt/conda/envs/py38/bin/gunicorn delete:app -b 0.0.0.0:8000 --reload -k utils.r_uvicorn_worker.RestartableUvicornWorker \n\
  74. autorestart=true\n\
  75. startretries=1000\n\
  76. redirect_stderr=true\n\
  77. stdout_logfile=/var/log/cron.log\n\
  78. stdout_logfile_maxbytes=5MB\n\
  79. environment=PYTHONUNBUFFERED=1\n\
  80. " > /etc/supervisor/conf.d/cron.conf
  81. EXPOSE 8000
  82. FROM builder2 as image-dev
  83. RUN apt-get update && apt-get install -y --no-install-recommends krb5-user
  84. ADD . ${WORKDIR}
  85. RUN mv docker/dev/krb5.conf /etc/
  86. FROM builder2 as image-test
  87. RUN apt-get update && apt-get install -y --no-install-recommends krb5-user
  88. ADD . ${WORKDIR}
  89. RUN mv docker/test/krb5.conf /etc/
  90. FROM builder2 as image-txprod
  91. RUN apt-get update && apt-get install -y --no-install-recommends krb5-user
  92. ADD . ${WORKDIR}
  93. RUN mv docker/txprod/krb5.conf /etc/
  94. FROM builder2 as image-idctest
  95. RUN apt-get update
  96. RUN apt-get update && apt-get install -y --no-install-recommends krb5-user
  97. ADD . ${WORKDIR}
  98. FROM builder2 as image-idcprod
  99. RUN apt-get update
  100. RUN apt-get update && apt-get install -y --no-install-recommends krb5-user
  101. ADD . ${WORKDIR}
  102. FROM builder2 as image-sxkj
  103. #RUN apt-get update
  104. #RUN apt-get update && apt-get install -y --no-install-recommends krb5-user
  105. ADD . ${WORKDIR}
  106. # FROM builder2 as builder3
  107. # RUN apt-get update && apt-get install -y --no-install-recommends openssh-server && rm -rf /var/lib/apt/lists/*
  108. # RUN mkdir /var/run/sshd
  109. # RUN echo 'root:root' | chpasswd
  110. # RUN sed -i 's/.*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config
  111. # # SSH login fix. Otherwise user is kicked off after login
  112. # RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
  113. # RUN echo "\
  114. # [program:sshd] \n\
  115. # command=/usr/sbin/sshd -D\n\
  116. # autorestart=True\n\
  117. # autostart=True\n\
  118. # redirect_stderr = true\n\
  119. # " > /etc/supervisor/conf.d/sshd.conf
  120. # EXPOSE 22
  121. # RUN mamba install -y jupyterlab -n base && mamba init zsh
  122. # RUN /opt/conda/bin/jupyter notebook --generate-config && \
  123. # echo "c.NotebookApp.password='argon2:\$argon2id\$v=19\$m=10240,t=10,p=8\$+zIUCF9Uk2FiCHlV8njX5A\$I5Mm/64DORArcXYTXWRVng'">>/root/.jupyter/jupyter_notebook_config.py
  124. # RUN mkdir -p /data && echo "\
  125. # [program:jupyter]\n\
  126. # directory=/data\n\
  127. # command=/opt/conda/bin/jupyter lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser \n\
  128. # autorestart=true\n\
  129. # startretries=0\n\
  130. # redirect_stderr=true\n\
  131. # stdout_logfile=/dev/stdout\n\
  132. # stdout_logfile_maxbytes=0\n\
  133. # " > /etc/supervisor/conf.d/jupyter.conf
  134. # EXPOSE 8888