Dockerfile 4.6 KB

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