PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/timApp/Dockerfile

https://gitlab.com/tim-jyu/tim
Dockerfile | 267 lines | 214 code | 26 blank | 27 comment | 49 complexity | 3c804f822fd8e23a2555d005a092cfce MD5 | raw file
  1. FROM ubuntu:20.04
  2. ENV APT_INSTALL="DEBIAN_FRONTEND=noninteractive apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get -q install --no-install-recommends -y" \
  3. APT_CLEANUP="rm -rf /var/lib/apt/lists /dvisvgm-2.4 /usr/share/doc ~/.cache"
  4. # Configure timezone and locale
  5. RUN bash -c "${APT_INSTALL} locales tzdata && ${APT_CLEANUP}"
  6. RUN locale-gen en_US.UTF-8 && bash -c "${APT_CLEANUP}"
  7. ENV LANG=en_US.UTF-8 \
  8. LANGUAGE=en_US:en \
  9. LC_ALL=en_US.UTF-8
  10. RUN echo "Europe/Helsinki" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata && bash -c "${APT_CLEANUP}"
  11. # Install dependencies of texlive-full excluding packages that are not needed (such as documentation files).
  12. # This almost-full installation of TeX Live is needed for the latex-pdf printing functionality, as
  13. # TeX Live doesn't have an (MiKTeX/MacTeX-esque) auto-install functionality for missing LaTeX packages,
  14. # i.e. the whole package archive needs to be pre-installed or the set of usable packages needs to be
  15. # severely limited.
  16. RUN bash -c "${APT_INSTALL} \
  17. biber \
  18. ca-certificates \
  19. cm-super \
  20. dvidvi \
  21. dvipng \
  22. feynmf \
  23. fonts-texgyre \
  24. fragmaster \
  25. latex-cjk-all \
  26. latexmk \
  27. lcdf-typetools \
  28. lmodern \
  29. psutils \
  30. purifyeps \
  31. software-properties-common \
  32. t1utils \
  33. tex-gyre \
  34. texlive-base \
  35. texlive-bibtex-extra \
  36. texlive-binaries \
  37. texlive-extra-utils \
  38. texlive-font-utils \
  39. texlive-fonts-extra \
  40. texlive-fonts-recommended \
  41. texlive-formats-extra \
  42. texlive-games \
  43. texlive-humanities \
  44. texlive-lang-arabic \
  45. texlive-lang-chinese \
  46. texlive-lang-cjk \
  47. texlive-lang-cyrillic \
  48. texlive-lang-czechslovak \
  49. texlive-lang-english \
  50. texlive-lang-european \
  51. texlive-lang-french \
  52. texlive-lang-german \
  53. texlive-lang-greek \
  54. texlive-lang-italian \
  55. texlive-lang-japanese \
  56. texlive-lang-korean \
  57. texlive-lang-other \
  58. texlive-lang-polish \
  59. texlive-lang-portuguese \
  60. texlive-lang-spanish \
  61. texlive-latex-base \
  62. texlive-latex-extra \
  63. texlive-latex-recommended \
  64. texlive-luatex \
  65. texlive-metapost \
  66. texlive-music \
  67. texlive-pictures \
  68. texlive-pstricks \
  69. texlive-publishers \
  70. texlive-science \
  71. texlive-xetex \
  72. wget \
  73. && ${APT_CLEANUP}"
  74. # Update dvisvgm so that it supports converting PDFs to SVGs
  75. ENV DVISVGM_VERSION="2.12"
  76. RUN bash -c "${APT_INSTALL} gcc g++ libgs-dev libkpathsea-dev pkg-config libfreetype6-dev make && ${APT_CLEANUP}"
  77. RUN FILE=`mktemp`; wget "https://github.com/mgieseki/dvisvgm/releases/download/${DVISVGM_VERSION}/dvisvgm-${DVISVGM_VERSION}.tar.gz" -qO $FILE && \
  78. tar -xf $FILE && \
  79. cd dvisvgm-$DVISVGM_VERSION && \
  80. ./configure --enable-bundled-libs && \
  81. make -j4 && \
  82. make install && \
  83. cd / && \
  84. ${APT_CLEANUP} && \
  85. rm -rf /dvisvgm-$DVISVGM_VERSION
  86. # Install Python, pip and other necessary packages
  87. RUN bash -c "add-apt-repository -y ppa:deadsnakes/ppa && ${APT_CLEANUP}"
  88. RUN bash -c "${APT_INSTALL} openssh-server python3.10 python3.10-distutils && ${APT_CLEANUP}"
  89. RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 20
  90. # lxml dependencies
  91. # C-parser for PyYAML
  92. # python-magic dependency
  93. RUN bash -c "${APT_INSTALL} \
  94. git-core \
  95. libffi-dev \
  96. libmagic1 \
  97. libmagickwand-dev \
  98. libvoikko1 \
  99. libxml2-dev \
  100. libxmlsec1-dev \
  101. libxmlsec1-openssl \
  102. libxslt-dev \
  103. libyaml-dev \
  104. python3.10-dev \
  105. voikko-fi \
  106. zlib1g-dev \
  107. && ${APT_CLEANUP}"
  108. RUN wget -q https://bootstrap.pypa.io/get-pip.py && python3.10 get-pip.py && rm get-pip.py
  109. ENV PIP_INSTALL="python3.10 -m pip install"
  110. RUN bash -c "${PIP_INSTALL} wheel setuptools && ${APT_CLEANUP}"
  111. RUN bash -c "${PIP_INSTALL} \
  112. attrs \
  113. authlib==1.0.0rc1 \
  114. autopep8 \
  115. beautifulsoup4 \
  116. bcrypt \
  117. bleach \
  118. celery[redis]==4.4 \
  119. cffi \
  120. cssselect \
  121. docformatter \
  122. filelock \
  123. flask \
  124. flask-apispec \
  125. flask-assets \
  126. flask-caching \
  127. flask-compress \
  128. flask-migrate \
  129. flask-oidc \
  130. flask-openid \
  131. flask-sqlalchemy \
  132. flask-testing \
  133. flask-wtf \
  134. gevent \
  135. git+https://github.com/miracle2k/webassets.git \
  136. gunicorn \
  137. html5lib \
  138. httpagentparser \
  139. humanize \
  140. isodate \
  141. langcodes[data] \
  142. libsass \
  143. lxml \
  144. mailmanclient \
  145. marshmallow \
  146. marshmallow-enum \
  147. marshmallow_union \
  148. mmh3 \
  149. mypy \
  150. pandocfilters \
  151. pillow \
  152. psycogreen \
  153. psycopg2-binary \
  154. pyaml \
  155. pylatex \
  156. pypandoc \
  157. python-dateutil \
  158. python-magic \
  159. python3-saml \
  160. pytz \
  161. recommonmark \
  162. responses \
  163. selenium \
  164. sphinx \
  165. sqlalchemy\<1.4.0 \
  166. sqlalchemy-utils \
  167. typing-inspect \
  168. voikko \
  169. wand \
  170. webargs==5.5 \
  171. && ${PIP_INSTALL} requests six --upgrade && ${APT_CLEANUP}"
  172. # Install typings for MyPy
  173. RUN bash -c "${PIP_INSTALL} \
  174. types-bleach \
  175. types-filelock \
  176. types-python-dateutil \
  177. types-pytz \
  178. types-PyYAML \
  179. types-redis \
  180. types-requests \
  181. && ${APT_CLEANUP}"
  182. # Install Pandoc
  183. RUN FILE=`mktemp`; wget "https://github.com/jgm/pandoc/releases/download/2.14.2/pandoc-2.14.2-1-amd64.deb" -qO $FILE && \
  184. dpkg -i $FILE && rm $FILE && bash -c "${APT_CLEANUP}"
  185. # Set name and email for git.
  186. RUN git config --global user.email "agent@docker.com" && git config --global user.name "agent"
  187. RUN git config --global --add safe.directory /service
  188. RUN mkdir /service
  189. # Add user `agent` -- we don't want to run anything as root.
  190. RUN useradd -M agent
  191. RUN chown -R agent /service
  192. RUN bash -c "${APT_INSTALL} curl qpdf gpg-agent poppler-utils && ${APT_CLEANUP} && \
  193. curl --version && qpdf --version"
  194. # On current TIM production server, using latest versions of Node and NPM will cause
  195. # ./npmi and ./js scripts to fail, causing the following symptoms:
  196. #
  197. # * ./npmi simply freezes right away, consuming memory until an out of memory exception is thrown.
  198. # * ./js does not freeze, but it throws a permission error after building scripts when trying to copy them to the final
  199. # output directory.
  200. #
  201. # It has not yet been investigated whether it's because of Node or NPM update.
  202. RUN (curl -sL https://deb.nodesource.com/setup_16.x | bash -) && bash -c "${APT_INSTALL} nodejs && ${APT_CLEANUP}"
  203. RUN npm i npm@6.14.8 -g && bash -c "${APT_CLEANUP}"
  204. RUN mkdir /var/run/sshd
  205. RUN echo 'root:test' | chpasswd
  206. RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
  207. # Flask-Testing does not let us configure host, so we do it here.
  208. RUN sed -i "s/port=port, use_reloader=False/host='0.0.0.0', port=port, use_reloader=False/" /usr/local/lib/python3.10/dist-packages/flask_testing/utils.py
  209. # Fix newest Werkzeug incompatibility
  210. RUN sed -i "s/from werkzeug import cached_property/from werkzeug.utils import cached_property/" /usr/local/lib/python3.10/dist-packages/flask_testing/utils.py
  211. RUN wget -q http://mirrors.ctan.org/support/latexmk/latexmk.pl -O /usr/bin/latexmk
  212. # Chromedriver (for running tests)
  213. # Taken from https://github.com/SeleniumHQ/docker-selenium/blob/trunk/NodeChrome/Dockerfile
  214. ARG CHROME_VERSION="google-chrome-stable"
  215. RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
  216. && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
  217. && apt-get update -qqy \
  218. && apt-get -qqy install unzip \
  219. ${CHROME_VERSION:-google-chrome-stable} \
  220. && rm /etc/apt/sources.list.d/google-chrome.list \
  221. && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
  222. RUN wget -q https://raw.githubusercontent.com/SeleniumHQ/docker-selenium/trunk/NodeChrome/wrap_chrome_binary -O /usr/local/bin/wrap_chrome_binary && chmod +x /usr/local/bin/wrap_chrome_binary
  223. RUN /usr/local/bin/wrap_chrome_binary
  224. ARG CHROME_DRIVER_VERSION
  225. RUN if [ -z "$CHROME_DRIVER_VERSION" ]; \
  226. then CHROME_MAJOR_VERSION=$(google-chrome --version | sed -E "s/.* ([0-9]+)(\.[0-9]+){3}.*/\1/") \
  227. && CHROME_DRIVER_VERSION=$(wget --no-verbose -O - "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION}"); \
  228. fi \
  229. && echo "Using chromedriver version: "$CHROME_DRIVER_VERSION \
  230. && wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
  231. && rm -rf /opt/selenium/chromedriver \
  232. && unzip /tmp/chromedriver_linux64.zip -d /opt/selenium \
  233. && rm /tmp/chromedriver_linux64.zip \
  234. && mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
  235. && chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
  236. && ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
  237. WORKDIR /service
  238. CMD python3 launch.py
  239. EXPOSE 22
  240. EXPOSE 5000
  241. EXPOSE 5001