Dockerfile 4.9 KB

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